Skip to content

Commit dc0f5e8

Browse files
authored
Remove the redundant DatastoreHistoryTaskSource.afterDays field. (#1000)
1 parent 040cf3a commit dc0f5e8

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

app/lib/analyzer/task_sources.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import '../shared/task_scheduler.dart';
1111
import '../shared/task_sources.dart';
1212
import '../shared/versions.dart';
1313

14+
import 'backend.dart' show reanalyzeThreshold;
1415
import 'models.dart';
1516

1617
/// Creates a task when a version uploaded in the past 10 minutes has no
@@ -32,13 +33,14 @@ class AnalyzerDatastoreHeadTaskSource extends DatastoreHeadTaskSource {
3233
}
3334
}
3435

35-
/// Creates a task when the most recent analysis is older than 30 days.
36+
/// Creates a task when the most recent analysis is older than
37+
/// [reanalyzeThreshold] days.
3638
class AnalyzerDatastoreHistoryTaskSource extends DatastoreHistoryTaskSource {
3739
final DatastoreDB _db;
3840

3941
AnalyzerDatastoreHistoryTaskSource(DatastoreDB db)
4042
: _db = db,
41-
super(db, afterDays: 30);
43+
super(db);
4244

4345
@override
4446
Future<bool> requiresUpdate(String packageName, String packageVersion,
@@ -58,7 +60,7 @@ class AnalyzerDatastoreHistoryTaskSource extends DatastoreHistoryTaskSource {
5860

5961
final Duration diff =
6062
new DateTime.now().toUtc().difference(version.analysisTimestamp);
61-
if (diff.inDays >= afterDays) return true;
63+
if (diff >= reanalyzeThreshold) return true;
6264

6365
if (retryFailed &&
6466
version.analysisStatus != AnalysisStatus.success &&

app/lib/dartdoc/backend.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import 'models.dart';
1717

1818
final Logger _logger = new Logger('pub.dartdoc.backend');
1919

20-
final Duration _entryUpdateThreshold = const Duration(days: 30);
20+
final Duration entryUpdateThreshold = const Duration(days: 90);
2121
final Duration _contentDeleteThreshold = const Duration(days: 1);
2222

2323
/// Sets the dartdoc backend.
@@ -95,7 +95,7 @@ class DartdocBackend {
9595
return true;
9696
}
9797
final age = new DateTime.now().difference(entry.timestamp).abs();
98-
if (age > _entryUpdateThreshold) {
98+
if (age > entryUpdateThreshold) {
9999
return true;
100100
}
101101
return false;

app/lib/dartdoc/task_sources.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ class DartdocDatastoreHeadTaskSource extends DatastoreHeadTaskSource {
2525
}
2626
}
2727

28-
/// Creates a task when the most recent dartdoc run is older than 30 days.
28+
/// Creates a task when the most recent dartdoc run is older than
29+
/// [entryUpdateThreshold] days.
2930
class DartdocDatastoreHistoryTaskSource extends DatastoreHistoryTaskSource {
30-
DartdocDatastoreHistoryTaskSource(DatastoreDB db) : super(db, afterDays: 30);
31+
DartdocDatastoreHistoryTaskSource(DatastoreDB db) : super(db);
3132

3233
@override
3334
Future<bool> requiresUpdate(String packageName, String packageVersion,
@@ -42,7 +43,7 @@ class DartdocDatastoreHistoryTaskSource extends DatastoreHistoryTaskSource {
4243

4344
final now = new DateTime.now().toUtc();
4445
final age = now.difference(entry.timestamp).abs();
45-
if (age.inDays >= afterDays) {
46+
if (age >= entryUpdateThreshold) {
4647
return true;
4748
}
4849

app/lib/shared/task_sources.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,11 @@ class DatastoreHeadTaskSource implements TaskSource {
102102
new Task(a.packageName, a.packageVersion, a.timestamp);
103103
}
104104

105-
/// Creates a task when the most recent output is older than [afterDays] days.
105+
/// Creates a task when the most recent output requires an update (e.g. too old).
106106
abstract class DatastoreHistoryTaskSource implements TaskSource {
107107
final DatastoreDB _db;
108-
final int afterDays;
109108

110-
DatastoreHistoryTaskSource(
111-
this._db, {
112-
this.afterDays: 30,
113-
});
109+
DatastoreHistoryTaskSource(this._db);
114110

115111
Future<bool> requiresUpdate(String packageName, String packageVersion,
116112
{bool retryFailed: false});

0 commit comments

Comments
 (0)