|
2 | 2 | // for details. All rights reserved. Use of this source code is governed by a |
3 | 3 | // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
|
| 5 | +import 'package:_pub_shared/data/download_counts_data.dart'; |
5 | 6 | import 'package:basics/basics.dart'; |
6 | 7 | import 'package:collection/collection.dart' show IterableExtension; |
7 | 8 | import 'package:json_annotation/json_annotation.dart'; |
8 | 9 | import 'package:pub_semver/pub_semver.dart'; |
9 | 10 | part 'download_counts.g.dart'; |
10 | 11 |
|
11 | | -/// A [VersionRangeCount] is a tuple containing a version range and a list of |
12 | | -/// download counts for periods of same length. |
13 | | -/// |
14 | | -/// The first entry in the tuple is a string describing the `versionRange`, for |
15 | | -/// instance '>=1.0.0-0 <2.0.0'. |
16 | | -/// |
17 | | -/// The second entry in the tuple is an integer list of `counts` with download |
18 | | -/// counts for each period. A period could for instance be a day, or a week etc. |
19 | | -/// The `counts` list contains at most [maxAge] entries. |
20 | | -/// |
21 | | -/// Consider the example of period being one day. The first count represents the |
22 | | -/// number of downloads on `newestDate` followed by the downloads on |
23 | | -/// `newestDate` - 1 and so on. E.g. |
24 | | -/// |
25 | | -/// counts = [ 42, 21, 55 ] |
26 | | -/// ▲ ▲ ▲ |
27 | | -/// │ │ └──────────── Download count on newestDate - 2 days |
28 | | -/// │ │ |
29 | | -/// │ └──────────────── Download count on newestDate - 1 day |
30 | | -/// │ |
31 | | -/// └──────────────────── Download count on newestDate |
32 | | -/// |
33 | | -/// |
34 | | -/// Each entry in the `counts` list is non-negativ. A `0` entry can for a given |
35 | | -/// day mean that the version range has no downloads or that there is no data. |
36 | | -typedef VersionRangeCount = ({String versionRange, List<int> counts}); |
37 | | - |
38 | 12 | /// The maximum number of days for which we store downloads counts for a package. |
39 | 13 | const maxAge = 731; |
40 | 14 |
|
@@ -242,46 +216,3 @@ class WeeklyDownloadCounts { |
242 | 216 | _$WeeklyDownloadCountsFromJson(json); |
243 | 217 | Map<String, dynamic> toJson() => _$WeeklyDownloadCountsToJson(this); |
244 | 218 | } |
245 | | - |
246 | | -@JsonSerializable(includeIfNull: false) |
247 | | -class WeeklyVersionDownloadCounts { |
248 | | - /// An integer list where each number is the total number of downloads for a |
249 | | - /// given 7 day period starting from [newestDate]. |
250 | | - final List<int> totalWeeklyDownloads; |
251 | | - |
252 | | - /// A list of [VersionRangeCount] with major version ranges and weekly |
253 | | - /// downloads for these ranges. |
254 | | - /// |
255 | | - /// E.g. each number in the `counts` list is the total number of downloads for |
256 | | - /// the range in a 7 day period starting from [newestDate]. |
257 | | - final List<VersionRangeCount> majorRangeWeeklyDownloads; |
258 | | - |
259 | | - /// A list of [VersionRangeCount] with minor version ranges and weekly |
260 | | - /// downloads for these ranges. |
261 | | - /// |
262 | | - /// E.g. each number in the `counts` list is the total number of downloads for |
263 | | - /// the range in a 7 day period starting from [newestDate]. |
264 | | - final List<VersionRangeCount> minorRangeWeeklyDownloads; |
265 | | - |
266 | | - /// A list of [VersionRangeCount] with patch version ranges and weekly |
267 | | - /// downloads for these ranges. |
268 | | - /// |
269 | | - /// E.g. each number in the `counts` list is the total number of downloads for |
270 | | - /// the range in a 7 day period starting from [newestDate]. |
271 | | - final List<VersionRangeCount> patchRangeWeeklyDownloads; |
272 | | - |
273 | | - /// The newest date with download counts data available. |
274 | | - final DateTime newestDate; |
275 | | - |
276 | | - WeeklyVersionDownloadCounts({ |
277 | | - required this.newestDate, |
278 | | - required this.majorRangeWeeklyDownloads, |
279 | | - required this.minorRangeWeeklyDownloads, |
280 | | - required this.patchRangeWeeklyDownloads, |
281 | | - required this.totalWeeklyDownloads, |
282 | | - }); |
283 | | - |
284 | | - factory WeeklyVersionDownloadCounts.fromJson(Map<String, dynamic> json) => |
285 | | - _$WeeklyVersionDownloadCountsFromJson(json); |
286 | | - Map<String, dynamic> toJson() => _$WeeklyVersionDownloadCountsToJson(this); |
287 | | -} |
0 commit comments