From 645c21d2a520908e92f369f3df1126fe72678eae Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Sat, 21 Nov 2026 14:58:38 +1030 Subject: [PATCH 1/2] feat: add the half-year activity scale to the API --- app/Http/Controllers/Api/UserController.php | 4 +--- tests/Feature/Controllers/Api/UserControllerTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 0a054ff9b..1b1725481 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -4,7 +4,6 @@ namespace App\Http\Controllers\Api; -use App\Enums\ActivityScale; use App\Http\Requests\ShowApiUserRequest; use App\Http\Resources\CommitResource; use App\Http\Resources\UserResource; @@ -40,8 +39,7 @@ public function show(ShowApiUserRequest $request, #[CurrentUser] ?User $currentU 'follows_you' => $user->isFollowing($currentUser), 'is_muting' => $currentUser->isMuting($user), 'pasteis_received' => $user->pasteis_received, - // API clients don't know the half-year scale yet, so they keep getting the year for anyone past a month. - 'activity' => $activity->get($user, $currentUser, scales: [ActivityScale::Day, ActivityScale::Week, ActivityScale::Month]), + 'activity' => $activity->get($user, $currentUser), 'streaks' => $userStreaks, 'achievements' => $achievements->get($user, $currentUser, $userStreaks), 'pinned_commit' => $pinnedCommit instanceof Commit ? CommitResource::make($pinnedCommit) : null, diff --git a/tests/Feature/Controllers/Api/UserControllerTest.php b/tests/Feature/Controllers/Api/UserControllerTest.php index f09f04a32..03191306a 100644 --- a/tests/Feature/Controllers/Api/UserControllerTest.php +++ b/tests/Feature/Controllers/Api/UserControllerTest.php @@ -180,7 +180,7 @@ expect(json_decode($response->getContent(), flags: JSON_THROW_ON_ERROR)->bio_profiles)->toBeInstanceOf(stdClass::class); }); -it('keeps API clients on the year for a profile whose first visible commit is two months old', function (): void { +it('returns the half scale for a profile whose first visible commit is two months old', function (): void { $this->travelTo(now()->setDate(2026, 10, 15)->setTime(12, 0)); $keyPair = apiKeyPairFor(User::factory()->create()); @@ -190,9 +190,9 @@ signedApiRequest($keyPair, 'GET', route('api-user.show', $user)) ->assertOk() - ->assertJsonPath('activity.scale', 'year') - ->assertJsonCount(369, 'activity.buckets') - ->assertJsonPath('activity.buckets.0.date', '2025-10-12'); + ->assertJsonPath('activity.scale', 'half') + ->assertJsonCount(180, 'activity.buckets') + ->assertJsonPath('activity.buckets.0.date', '2026-04-19'); }); it('counts the pending commits of a signed-in user on their own profile', function (): void { From 94ab88af5295037afa0d02d85a774adaa6c19fcd Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Sat, 21 Nov 2026 16:12:11 +1030 Subject: [PATCH 2/2] docs: note that the signed API returns the activity graph's half-year range --- KNOWLEDGE_BASE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/KNOWLEDGE_BASE.md b/KNOWLEDGE_BASE.md index 6965f9e74..d346002de 100644 --- a/KNOWLEDGE_BASE.md +++ b/KNOWLEDGE_BASE.md @@ -587,6 +587,7 @@ An app can use the same `/api/v1` for you with signed requests. It keeps an SSH A signed request sees what the web shows you, such as your own pending commits and your organizations'. It can also, with the web's validation, moderation, and rate limits: - read your account, logs, replies, notifications (including grouped activity), and starred commits; +- read a profile's activity graph over the same range as the web: the last 24 hours, 7 days, 30 days, 6 months, or a year; - read the organizations you are a member of, your role in each, and whether posting as an organization is switched on; - open the person or organization a mention in a commit or message captured, by the id each mention carries, as the web's mention links do, so it still leads to them after they rename and someone else takes the handle; - commit, reply, and quote, with images, and delete your commits, with the same undo window as the web;