Skip to content

Draw a commit graph scale the app doesn't know as a year - #199

Merged
simonhamp merged 1 commit into
NativePHP:mainfrom
shanesmithdev:fix-unknown-activity-scale
Nov 21, 2026
Merged

simonhamp merged 1 commit into
NativePHP:mainfrom
shanesmithdev:fix-unknown-activity-scale

Conversation

@shanesmithdev

@shanesmithdev shanesmithdev commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

A profile's commit activity comes from devnull with a scale of day, week, month or year. If the scale was anything else, the app dropped the whole response. The profile then said "0 commits in the last year" over an empty strip. A scale that wasn't a string, such as an array, threw an error and broke the profile screen.

dev-null-sh/dev-null.sh#1658 proposes a half scale: 26 weeks of daily buckets for profiles 30 days to 6 months old. Without this change, someone two months in would see "0 commits in the last year" in the app as soon as that ships. That PR may not merge, but devnull could add a scale at any time, so this makes the app ready for one either way.

Fix

  • Activity::fromArray() now draws a scale it doesn't know, or one that's missing or not a string, as a year, keeping its buckets.
  • Daily buckets are summed a week to a cell, as they are for a year, and the header reads "N commits in the last year".
  • For half, that's 26 cells, and the count is right, because devnull only sends half when nothing visible is older than 26 weeks (if the dependent PR is merged, otherwise it never sends half).

The app still only knows day, week, month and year, so nothing here depends on #1658. If that is merged, we could add support for half (or any future scale) at our own pace without the app displaying an error.

Tests

A new test in tests/Unit/Devnull/ActivityTest.php reads 91 days under an unknown quarter scale.

  • Without the change, it fails: no cells, and no commits.
  • With the change, ActivityTest.php and ProfileTest.php pass (38 passed).

I didn't run this on a device. It depends on the API sending an unknown value to reproduce it.

Screenshots

  • No visible change

A profile's commit activity comes from devnull with a scale of day,
week, month or year. If the scale was anything else, the app dropped
the whole response, so the profile said "0 commits in the last year"
over an empty strip. A scale that wasn't a string, such as an array,
threw an error and broke the profile screen.

A scale the app doesn't know, or one that's missing or not a string,
is now drawn as a year and keeps its buckets. dev-null-sh/dev-null.sh#1658
proposes a half scale, which then shows as 26 weekly cells, but nothing
here depends on it merging.
@simonhamp
simonhamp merged commit 4b6dafd into NativePHP:main Nov 21, 2026
3 checks passed
@shanesmithdev
shanesmithdev deleted the fix-unknown-activity-scale branch November 21, 2026 11:13
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.

2 participants