[openstreetmap/openstreetmap-website] Add user profile heatmap visualization for contributions (PR #5402)

Tom Hughes notifications at github.com
Sun Mar 9 10:53:22 UTC 2025


@tomhughes requested changes on this pull request.



> +
+  let cal = new CalHeatmap();
+  let currentTheme = getTheme();
+
+  function renderHeatmap() {
+    cal.destroy();
+    cal = new CalHeatmap();
+
+    cal.paint({
+      itemSelector: "#cal-heatmap",
+      theme: currentTheme,
+      domain: {
+        type: "month",
+        gutter: 4,
+        label: {
+          text: (timestamp) => I18n.strftime(new Date(2000, new Date(timestamp).getMonth(), 15), "%b"),

If we've constructed a date from the timestamp why do you then extract the month from that and build a new date? If the format only uses the month the rest of the date doesn't matter?

It might a bit faster to just lookup `I18n.t("date.abbr_month_names")` once before the paint call and then index that array with the month number rather than calling strftime repeatedly - just beware of 0/1 based indexing!

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5402#pullrequestreview-2669390875
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5402/review/2669390875 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250309/8ced18ed/attachment.htm>


More information about the rails-dev mailing list