-
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
Conversation
| .withCodec(utf8) | ||
| .withCodec(json) | ||
| .withCodec(wrapAsCodec( | ||
| encode: (WeeklyDownloadCounts wdc) => wdc.toJson(), | ||
| decode: (d) => WeeklyDownloadCounts.fromJson(d as Map<String, dynamic>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 .withCodec(utf8).
So why not just store:
base64.encode(Uint8List.sublistView(Uint32List.fromList(dataPoints)));Or:
return Uint8List.sublistView(Uint32List.fromList(dataPoints));
jonasfj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll name to name options for the widget as data-<widget>-<option>.
So if you have data-widget="weekly-sparkline" the points option should be: data-weekly-sparkline-points="...".
| } | ||
|
|
||
| @JsonSerializable(includeIfNull: false) | ||
| class WeeklyDownloadCounts { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
No description provided.