Skip to content

Commit 672423d

Browse files
committed
Add last partial week
1 parent 9c74387 commit 672423d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

app/lib/service/download_counts/computations.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Future<({List<int> weeklyPoints, DateTime? newestDate})> computeWeeklyDownloads(
5757
var sum = 0;
5858
for (int i = 0; i < 52 * 7; i++) {
5959
if (totals[i] < 0) {
60+
weeklyPoints[(i ~/ 7)] = sum;
6061
// There is no more available data.
6162
break;
6263
}

app/test/service/download_counts/computations_test.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ void main() {
142142
'6.1.0': 3,
143143
};
144144

145-
for (var i = 0; i < 7 * 20; i++) {
145+
for (var i = 0; i <= 7 * 20; i++) {
146146
await downloadCountsBackend.updateDownloadCounts(
147147
pkg, versionsCounts, date.addCalendarDays(i));
148148
}
149149

150-
for (var i = 7 * 20; i < 7 * 40; i++) {
150+
for (var i = 7 * 20 + 1; i <= 7 * 40; i++) {
151151
await downloadCountsBackend.updateDownloadCounts(
152152
pkg, versionsCounts2, date.addCalendarDays(i));
153153
}
@@ -156,8 +156,9 @@ void main() {
156156

157157
final expectedList = List.from(List.filled(20, 147))
158158
..addAll(List.filled(20, 98))
159-
..addAll(List.filled(12, 0));
160-
final expectedNewstDate = date.addCalendarDays(7 * 40 - 1);
159+
..add(14)
160+
..addAll(List.filled(11, 0));
161+
final expectedNewstDate = date.addCalendarDays(7 * 40);
161162

162163
expect(res.weeklyPoints, expectedList);
163164
expect(res.newestDate, expectedNewstDate);

0 commit comments

Comments
 (0)