-
Notifications
You must be signed in to change notification settings - Fork 166
Add widget for weekly downloads chart with downloads data #8208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,3 +215,18 @@ class CountData { | |
| _$CountDataFromJson(json); | ||
| Map<String, dynamic> toJson() => _$CountDataToJson(this); | ||
| } | ||
|
|
||
| @JsonSerializable(includeIfNull: false) | ||
| class WeeklyDownloadCounts { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not pretty, but you could just pass around the binary encoding 🤣 Or the base64 encoding. This could also be used in the redis cache. Then you won't have to JSON decode, and reencode as binary for every request.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is indeed an optimization. But as you say it's not pretty. Also the other things we store in redis are human readable strings which is nice for debugging. |
||
| final List<int> weeklyDownloads; | ||
| final DateTime newestDate; | ||
|
|
||
| WeeklyDownloadCounts({ | ||
| required this.weeklyDownloads, | ||
| required this.newestDate, | ||
| }); | ||
|
|
||
| factory WeeklyDownloadCounts.fromJson(Map<String, dynamic> json) => | ||
| _$WeeklyDownloadCountsFromJson(json); | ||
| Map<String, dynamic> toJson() => _$WeeklyDownloadCountsToJson(this); | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,6 +247,16 @@ class CachePatterns { | |
| decode: (d) => CountData.fromJson(d as Map<String, dynamic>), | ||
| ))[package]; | ||
|
|
||
| Entry<WeeklyDownloadCounts> weeklyDownloadCounts(String package) => _cache | ||
| .withPrefix('weekly-download-counts/') | ||
| .withTTL(Duration(hours: 6)) | ||
| .withCodec(utf8) | ||
| .withCodec(json) | ||
| .withCodec(wrapAsCodec( | ||
| encode: (WeeklyDownloadCounts wdc) => wdc.toJson(), | ||
| decode: (d) => WeeklyDownloadCounts.fromJson(d as Map<String, dynamic>), | ||
|
Comment on lines
+253
to
+257
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default it's possible to store binary data in redis. That's why we have So why not just store: base64.encode(Uint8List.sublistView(Uint32List.fromList(dataPoints)));Or: return Uint8List.sublistView(Uint32List.fromList(dataPoints)); |
||
| ))[package]; | ||
|
|
||
| Entry<List<LikeData>> userPackageLikes(String userId) => _cache | ||
| .withPrefix('user-package-likes/') | ||
| .withTTL(Duration(minutes: 60)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.