archiveOldServices method
override
This function move old finished(and outDated) services to hiveArchive.
There are two reason to archive services, first - we want active hiveBox small and fast on all devices, second - we want worker to only see today's services, and services which didn't committed yet(stale/rejected).
Archive is only for committed services. Only hiveArchiveLimit number of services could be stored in archive, the oldest services will be deleted first.
Implementation
@override
Future<void> archiveOldServices() async {
final forDelete = _forArchive.toList();
if (forDelete.isNotEmpty) {
final res = await hiveRepository.archiveOldServices(forDelete);
//
// > delete finished old services and save hive
//
_deleteFromHive(forDelete);
return res;
}
}