Skip to content

feat(profile): show the user's real GitHub contribution graph (#61) - #68

Open
bae080311 wants to merge 11 commits into
Younesfdj:masterfrom
bae080311:feat/contribution-graph
Open

bae080311 wants to merge 11 commits into
Younesfdj:masterfrom
bae080311:feat/contribution-graph

Conversation

@bae080311

Copy link
Copy Markdown

What

Closes #61.

Adds the user’s actual GitHub contribution graph to the profile page.

This addresses the maintainer’s feedback:

  • Reuses the existing background grid’s cell size, radius, and green through shared GRID_* constants, rather than introducing a second grid style.
  • Uses the existing contributionCalendar GraphQL query, so no additional API request is made.
  • Adds a pure calendar transformation in lib/contributions.ts, covering weekday alignment, padding, intensity levels, streaks, and month labels.
  • Adds tests for the transformation logic.

The contribution days are flattened from the existing GraphQL response and passed through scout.ts onto Card. recentActiveDays is now derived from the same flattened data.

Screenshots

Notes

  • The public /api/card/:username response does not include contribution-day data, since it is only used by the server-rendered profile page.
  • Bumped the Redis card cache version because the Card shape changed.

Tests

  • npm test — 230 passed
  • npm run lint — 0 errors
  • npm run build — passed

An AI assistant helped with the implementation. I reviewed the changes and ran the tests, lint, and build locally.

bae080311 and others added 11 commits July 15, 2026 10:20
Reshapes a user's real per-day contribution counts into a rendering-ready
grid (Sun..Sat weeks, month labels, per-user quartile intensity levels,
current streak). Framework-agnostic and fetch-free so it's trivially
unit-tested on its own, ahead of wiring it into any UI.
…he profile fetch

The scout already requests contributionCalendar in the profile query, but
only reduced it to a single recentActiveDays count. Add `date` to the
existing field selection (no new API call) and flatten the calendar into
RawPayload.contributionDays; recentActiveDays now derives from that same
array instead of walking the tree twice.
Card gains an optional contributionDays field, attached alongside
buildCard's output in buildFresh rather than folded into Signals/buildCard
itself — it's display data for the profile page, not a scoring input.
Bumps the Redis cache version since this changes Card's cached shape.
Adds ContributionPanel — a real per-user grid rendered full-width below the
scouting report, styled like the other report panels. Reuses the decorative
Background motif's exact cell geometry and green (now exported as GRID_*
constants) so the page never shows two different-looking grids, and
suppresses that decorative strip only once a card actually has calendar data
to replace it with.
The public /api/card/:username response has no reason to carry ~365 extra
{date,count} rows per request — that data only feeds the profile page's own
ContributionPanel render, which already has it via the server-rendered Card.
Adding a fourth section (the contribution graph) pushed the result page
past typical laptop heights. Scale several previously width-only or fixed
values (card size, grade stamp, name, vertical margins) with viewport
height too, so the whole report — card, attributes, metrics, distribution,
contributions — fits without scrolling on common desktop sizes (~1512x980+)
and comes close on smaller ones (~1440x900), without touching the
mobile-stacked layout (still governed by the max-[980px] breakpoint).

Raised the card's width floor from 220 to 260 — CardActions' Download
button needs that much room before its label starts truncating, which the
more aggressive height-based shrinking would otherwise have hit.
…, not a new section

The standalone ContributionPanel section added real page height on top of an
already content-heavy result page, reintroducing the scroll it was meant to
avoid. Since the decorative grid motif in Background.tsx is purely an
absolutely-positioned layer (zero document-flow height), swapping in the
user's real per-day calendar there instead costs nothing extra — same spot,
same cell size/rounding/green, just real data instead of a seeded pattern.

Falls back to the fake pattern whenever there's no real calendar to show
(demo/sample cards, cards cached before contributionDays existed, or no card
at all), so every page still gets *a* motif, just not a fabricated one when
real data is available.

ContributionPanel.tsx is removed; lib/contributions.ts (the pure transform)
stays — Background now builds the real grid's SVG string from its output
directly, the same way it already did for the fake one.
업스트림의 awards/years 추가와 contribution graph 작업이 같은 자리에서 충돌해
양쪽을 모두 살리는 방향으로 해소했다.

- RawPayload·Card·스텁 픽스처: years와 contributionDays를 나란히 유지
- recentWindowQuery도 contributionDays에 date를 선택하도록 맞춤 — 업스트림이
  추가한 resource-limit 폴백이 RecentNode 타입을 one-shot 쿼리와 공유한다
- 캘린더를 날짜별로 합산 — 폴백이 두 윈도우를 이어붙이면서 경계일이 중복된다
- buildFresh: contributionDays 재부착과 computeAwards를 한 payload fetch로 통합
- CACHE_VERSION v2 -> v3: 두 v2가 서로 다른 Card 모양을 가리켜 무효화 필요

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: show GitHub contribution graph in the card background

1 participant