Repository navigation
feat(level): chart XP over time in /level check - #82
Merged
guirguispierre merged 1 commit intoOct 6, 2026
Merged
guirguispierre merged 1 commit into
guirguispierre merged 1 commit into
Conversation
Record cumulative XP per UTC day (xpByDay map) on each awardXP write, then render the last 30 days as a line chart in /level check replies. - src/utils/xpChart.js: text-free SVG chart rasterized via existing sharp dep (lazy-required; no <text> so it works without fontconfig) - /level check attaches xp-chart.png when >= 2 days of history exist, otherwise notes history is still being collected - chart render failure degrades to the plain stats embed - test/levelXpChart.test.js covers point building, SVG output, awardXP history writes, and /level check attachment behavior Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/level checknow shows a chart of XP over time, addressing the feature request for a visible XP history graph.There was no historical XP data — each
levelsdoc only stored the currentxptotal. This PR adds a boundedxpByDaymap ('YYYY-MM-DD'→ cumulative total XP, UTC) written in the existingawardXPset(..., { merge: true })call, so history accumulates at one field per day with no extra writes./level checkrenders the last 30 days as a line chart PNG and attaches it to the embed (attachment://xp-chart.png). The SVG is generated insrc/utils/xpChart.jsand rasterized withsharp— already a dependency — lazy-required so tests and non-chart paths never load the binary. The SVG deliberately contains no<text>elements:node:20-slimships no fontconfig fonts, so labels would render blank; the date range is conveyed in the embed footer instead.Behavior:
awardXPonward;xpByDay[today]correctly reflects the all-time total rather than only new XP.Tests
node --test— 550 tests pass, including 11 new intest/levelXpChart.test.jscoveringbuildXPChartPoints(sorting, today upsert, malformed keys, 30-day cap), text-free SVG output,awardXPxpByDaywrites/accumulation, and/level checkattachment + footer behavior.