Skip to content

feat: add the half-year activity scale to the API - #1658

Draft
shanesmithdev wants to merge 2 commits into
dev-null-sh:productionfrom
shanesmithdev:feat/api-activity-half-scale
Draft

shanesmithdev wants to merge 2 commits into
dev-null-sh:productionfrom
shanesmithdev:feat/api-activity-half-scale

Conversation

@shanesmithdev

@shanesmithdev shanesmithdev commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#1657 (merged) added a half-year activity scale (half, 26 weeks) for web profiles 30 days to 6 months old, and kept it out of the API. This PR adds half to the API.

This PR stays a draft until the app and TUI developers confirm they handle half.

Important

For app and TUI developers: GET /api/v1/users/{handle} can return "scale": "half" when the earliest commit the viewer can see (or the signup date, if there's none) is more than 30 days and up to 26 weeks old. Its buckets are daily, from a Sunday through today: 26 week columns, 176–182 buckets depending on the weekday. Drawing it like year works. All other ages are unchanged.

For a profile whose first visible commit is about 2 months old:

 "activity": {
-  "scale": "year",  // 371 daily buckets, 2025-11-16 → 2026-11-21
+  "scale": "half",  // 182 daily buckets, 2026-05-24 → 2026-11-21
   "buckets": [{ "date": "2026-05-24", "count": 0 }, …]
 }

Apps & TUI compatibility checklist

The goal is to make sure apps don't crash or show unexpected output when the API starts returning the new half scale.

Changes

  • Api\UserController@show drops the scales: argument feat: show a half-year activity grid on profiles under six months old #1657 added, so the API picks from the same scales as the web profile (ActivityScale::FITTING).
  • The API test now expects half, with 180 buckets starting on Sunday 2026-04-19, for a profile whose first visible commit is two months old.
  • KNOWLEDGE_BASE.md: the signed API section now says a profile's activity graph covers the same range as the web (24 hours, 7 days, 30 days, 6 months, or a year).

Validation

  • Targeted, after rebasing onto production with feat: show a half-year activity grid on profiles under six months old #1657 merged: tests/Feature/Controllers/Api/UserControllerTest.php and tests/Unit/Queries/UserActivityQueryTest.php, 45/45 passed. PHPStan: no errors.
  • Full composer test:unit, test:lint, test:types and test:type-coverage before the rebase: all passed. Pest 6515/6515 with 100% line coverage, Node unit tests 331/331, and 100% type coverage.
  • Hosted CI: waiting for a maintainer to approve workflows
  • Independent review (read-only, by someone other than the implementer) of the API change: Code: PASS, no blockers. Visual: N/A, because no frontend or web files changed. Non-blocking note: $scales is now only passed by a unit test, and it's kept deliberately.
  • Limitations: apps and TUIs that don't handle half may fail to draw the graph for profiles 30 days to 6 months old, hence the draft status for this PR.

I will check with the app and TUI developers that they know about this before taking the PR out of draft, because most of the apps I've seen would handle this badly right now. The checklist above shows which apps have been fixed.

@shanesmithdev
shanesmithdev marked this pull request as draft November 21, 2026 04:34
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

No actionable comments were generated in the recent review.

Walkthrough

Activity scale selection now includes a half-year window. The API can return that scale for activity within its range. The frontend renders half-year activity as a week grid, with updated summaries and month labels.

Changes: Half-year activity scale

Layer / File(s) Summary
Half-year scale selection and API behavior
app/Enums/ActivityScale.php, app/Queries/UserActivityQuery.php, app/Http/Requests/ShowSiteActivityRequest.php, tests/Feature/Controllers/Api/UserControllerTest.php, tests/Feature/Controllers/SiteActivityControllerTest.php, tests/Unit/Queries/UserActivityQueryTest.php
The scale and query support half-year windows and configurable candidate scales. The site request still accepts only Day, Week, Month, or Year. Tests cover scale selection, returned activity buckets, and request validation.
Half-year activity graph
resources/js/types/activity.ts, resources/js/components/activity-graph.tsx, tests/Unit/ActivityCells.test.tsx
The activity type and graph support half-year summaries and week-grid rendering. Tests cover summary text, grid dimensions, and month-label placement.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Possibly related PRs

Suggested reviewers: xheaven, jubianchi

Merge Risk: Low · previous review e1a8b

The API now returns a new "half" activity scale for profiles between 30 days and 6 months old. Any app or TUI client that does not recognise it may fail to draw the activity graph for those profiles. Confirm client support before merging; the web profile is already handled.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat: add the half-year activity scale to the API" matches the main change. The diff adds the Half case to ActivityScale, extends the query and the API profile response so profiles 30 days …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "feat: add the half-year activity scale to the API" matches the main change. The diff adds the Half case to ActivityScale, extends the query and the API profile response so profiles 30 days to 26 weeks old return the half scale, and adds the matching tests. The title names the feature and the surface it touches, so it describes the primary change without listing files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6ee8c048-8ca1-4fde-bc9e-04cff218a56e
Commits

Reviewing files that changed from the base of the PR and between 90f528e and e1a8b0d.

Files selected for processing: 9

  • app/Enums/ActivityScale.php
  • app/Http/Requests/ShowSiteActivityRequest.php
  • app/Queries/UserActivityQuery.php
  • resources/js/components/activity-graph.tsx
  • resources/js/types/activity.ts
  • tests/Feature/Controllers/Api/UserControllerTest.php
  • tests/Feature/Controllers/SiteActivityControllerTest.php
  • tests/Unit/ActivityCells.test.tsx
  • tests/Unit/Queries/UserActivityQueryTest.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

@shanesmithdev
shanesmithdev force-pushed the feat/api-activity-half-scale branch from 82e630e to 94ab88a Compare November 23, 2026 15:36
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.

1 participant