areMaterialsFresh method

Future<bool> areMaterialsFresh(
  1. int courseOfferingId
)

Checks whether the material list was fetched within courseMaterialsTtl.

Implementation

Future<bool> areMaterialsFresh(int courseOfferingId) async {
  final offering = await (_database.select(
    _database.courseOfferings,
  )..where((row) => row.id.equals(courseOfferingId))).getSingleOrNull();
  final fetchedAt = offering?.materialsFetchedAt;
  return fetchedAt != null &&
      DateTime.now().difference(fetchedAt) < courseMaterialsTtl;
}