-
Notifications
You must be signed in to change notification settings - Fork 923
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
Add user profile heatmap visualization for contributions #5402
base: master
Are you sure you want to change the base?
Conversation
b27b7a6
to
b134a0a
Compare
Oh, I forgot about this. |
It is a very minor nitpick, but is it possible to dynamically determine what's the first weekday based on the user's locale and adjust the heatmap accordingly? Intl.Locale.prototype.getWeekInfo() could be used. It isn't currently available in Firefox but all other browsers have it. P.S. Added bug 1937867 to Firefox's bug tracker. |
What's the source(s) of all the javascript in Also, how does the inclusion of popper interact with the popper already included? We end up with |
OK, I found the answer for the cal-heatmap part of the code, which is available as an npm module. In which case, using package.json will allow us to upgrade to new versions automatically, and would be the preferred option. |
UX thoughts:
Code comments:
|
I've tested the performance of the underlying query and using the user with the most changesets in the last year (just over 50 thousand) it took a fraction over one second which is probably acceptable. That result (which was a full 365 days of data) serialised to just under 10Kb which is a fair chunk to be caching but hopefully most entries will be smaller than that. |
Thank you for the suggestion. I’ll refactor accordingly to ensure alignment with the preferred color scheme setting.
I tried dynamically adjusting the start and end weekdays using ghDay as the subdomain, but it rounds to the first and last weeks of the month, making implementation tricky. Accommodating this would require significant effort, which may not be worth it for such a minor adjustment.
To be honest I wasn’t too familiar with how our assets pipeline works,so I just added the Thank you for pointing out the existing |
b134a0a
to
0a8fc14
Compare
0a8fc14
to
af02b6a
Compare
I've updated the code to account for the "Preferred Website Color Scheme." Theme settings should now be working correctly. UX Thoughts:
Code Comments:
Also a big thank you to @tomhughes for testing the performance here. |
How is it included in |
It's not going to work correctly because our Auto option follows Looks like cal-heatmap doesn't have a proper auto scheme "as not all websites support dark/light mode". You'd have to then setup a listener like this but without using Leaflet of course and redraw the heatmap. Same is true for #5426 by the way. |
Any other change to the theme of the page without reloading will break most of the CSS theming anyway since the stylesheets were split in #5362 by the way. It would be great to have a global leaflet-independent watcher where clients can add themselves to a callback list. |
You don't need to change the theme of the page, neither here, nor in #5426. Or do you say that you haven't tried switching
Leaflet code is just a wrapper for |
I did that for testing, but since listening increased the complexity unnecessarily, I left that for a second pass. But suppose the site needs a theme watcher anyway because the cal-heatmap doesn't want to let CSS do the color mixing theme-agnostically. In that case, instead of having two listeners, a common solution that includes MutationObservers outside of jQuery would be the one with the least overhead. |
Why MutationObservers? |
The MutationObserver thought came from my tinkering with the site locally wanting to reduce the reloads, forgetting that a toggle if added would already have onchange events.
Yeah, I kinda missed that... Still, having a similar style on such similar functions and having them moved to some unified location would be a nice thing to have, currently, they could be much more different. But that's more of a refactor thing if both are merged. |
Description
This PR addresses #5373 by adding a heatmap visualization on user profile pages to display daily contribution activity over the past year.
Key changes include:
users/show.html.erb
).heatmap.js
) using CalHeatmap to render the heatmap dynamically based on contribution data.config/locales/en.yml
) to include tooltips and month/weekday labels for the heatmap.users_controller_test.rb
to validate heatmap data handling.Screenshots:
How has this been tested?
Let me know if you need further tweaks or enhancements!