summaryrefslogtreecommitdiff
path: root/internal/showcase/rank_history_svg_test.go
AgeCommit message (Collapse)Author
11 daysshowcase: extend rank history to 32 weeks, trim leading empty columnsPaul Buetow
Previously the graph was fixed at 5 weekly data points. Now: - rankHistoryPoints raised from 5 → 32 so the store accumulates up to 32 weekly snapshots and each project carries 32 history entries. - GenerateRankHistorySVG trims all leading all-zero columns before layout, so the graph only spans from the oldest week that any project actually has data — no empty space on the left when history is short. - displayPoints (trimmed width) drives all layout math: xPos(), xLabels, and the X-axis loop; numPoints is only used for the reversal placement. - xLabelStep() thins X-axis text labels when many columns are visible (step 1 for ≤6, 2 for ≤12, 4 for ≤24, 8 for >24 columns) while still drawing a grid line at every column and always labelling 'now'. - Test: give alpha a Spot at '4w' so trimming keeps that column and the time-axis label test still finds '4w ago' in the output. - New TestXLabelStep_ReturnsSensibleSteps covers the new helper. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
11 daysfeat(showcase): add interactive SVG rank history graphPaul Buetow
Generate rank-history.svg alongside showcase.gmi.tpl on every showcase run (full or single-repo update). The graph shows a Google-Trends-style polyline per project from oldest to newest; hovering highlights the selected project and shows a tooltip with rank and snapshot date for each recorded week. Key implementation details: - new file internal/showcase/rank_history_svg.go with GenerateRankHistorySVG - golden-ratio HSL colour spacing for visually distinct project lines - M/L SVG path commands with gaps for weeks with no snapshot data - PROJECTS JSON array embedded in CDATA script for JS tooltip rendering - rank-history.svg linked from the gemtext showcase header Changes to showcase.go: - updateShowcaseFile returns ([]ProjectSummary, error) so the caller can pass the full merged+sorted list to writeRankHistorySVGFile - extract showcaseOutputDir() helper to deduplicate the hardcoded ~/git/foo.zone-content/gemtext/about path used in four places - log a warning (instead of silently continuing) when getRepositories fails inside updateShowcaseFile so data loss is visible to the operator Bug fixes found during review: - off-by-bounds panic: reversal loop used revIdx=numPoints-1-j as source index but numPoints is a constant (5) not len(s.RankHistory); replaced with j as source and numPoints-1-j as destination so partial slices never panic - redundant getElementById in JS onEnter replaced with allPG[idx] which is already the correct element Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>