Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/lib/task/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ class TaskBackend {
// Map from package to updated that has been seen.
final seen = <String, DateTime>{};

// We will schedule longer overlaps every 6 hours.
var nextLongScan = clock.fromNow(hours: 6);

// In theory 30 minutes overlap should be enough. In practice we should
// allow an ample room for missed windows, and 3 days seems to be large enough.
var since = clock.ago(days: 3);
Expand All @@ -298,8 +301,14 @@ class TaskBackend {
..filter('updated >', since)
..order('-updated');

// Next time we'll only consider changes since now - 5 minutes
since = clock.ago(minutes: 5);
if (clock.now().isAfter(nextLongScan)) {
// Next time we'll do a longer scan
since = clock.ago(days: 1);
nextLongScan = clock.fromNow(hours: 6);
} else {
// Next time we'll only consider changes since now - 30 minutes
since = clock.ago(minutes: 30);
}

// Look at all packages that has changed
await for (final p in q.run()) {
Expand Down