readLatestCachedCourseTable method

Future<LatestCachedCourseTable?> readLatestCachedCourseTable()

Reads the newest semester eligible for the course table without network access or interactive refresh side effects.

Implementation

Future<LatestCachedCourseTable?> readLatestCachedCourseTable() async {
  final semester =
      await (_database.select(_database.semesters)
            ..where((row) => row.inCourseSemesterList.equals(true))
            ..orderBy([
              (row) => OrderingTerm.desc(row.year),
              (row) => OrderingTerm.desc(row.term),
            ])
            ..limit(1))
          .getSingleOrNull();
  if (semester == null) return null;
  return (
    semester: semester,
    courseTable: (await _readCachedCourseTable(semester.id)).courseTable,
  );
}