From 66bef11ec1bb584b0d0139a58cbcf82235724b19 Mon Sep 17 00:00:00 2001 From: Kjell Kind Date: Wed, 11 Nov 2026 23:43:42 +0100 Subject: [PATCH 1/2] feat: count the commits that mention developers who aren't on /dev/null yet Their page says how many commits mention them and links to search with @handle filled in, instead of listing what others say about them. Co-Authored-By: Claude Opus 5.5 --- KNOWLEDGE_BASE.md | 4 +- .../UnclaimedProfileController.php | 7 +++- .../UnclaimedProfileMentionCountQuery.php | 41 +++++++++++++++++++ resources/js/pages/profile/unclaimed.tsx | 32 +++++++++++++-- .../UnclaimedProfileControllerTest.php | 15 +++++++ 5 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 app/Queries/UnclaimedProfileMentionCountQuery.php diff --git a/KNOWLEDGE_BASE.md b/KNOWLEDGE_BASE.md index c0dacdac00..8f5b9e9579 100644 --- a/KNOWLEDGE_BASE.md +++ b/KNOWLEDGE_BASE.md @@ -149,7 +149,9 @@ A developer who isn't here yet gets a page with their GitHub avatar, name, handl Its page shows how many members are waiting to follow them: the members who followed them on GitHub when they were looked up, and the ones who clicked **Follow** on their page, which then reads **Waiting** and can be clicked again to stop waiting. Members also see the people they follow among them. When the developer signs up, everyone waiting follows them, and their notifications show those follows like any others. Who you wait to follow is in your data export, and goes when you delete your account. If you delete your account, your page doesn't come back as one of these, until you sign in again. -Sources: [looking handles up](app/Http/Controllers/ProfileLookupController.php), [lookup page](resources/js/pages/profile/lookup.tsx), [developer page](resources/js/pages/profile/unclaimed.tsx), [GitHub lookups](app/Actions/CreateGitHubProfile.php). +Its page also says how many commits mention them, like **12 commits mention them**, counting approved commits that mention `@handle` outside code, refreshed within the hour. The commits themselves aren't shown there, since they can't answer what's said about them: the count links to search with `@handle` filled in, for members. + +Sources: [looking handles up](app/Http/Controllers/ProfileLookupController.php), [lookup page](resources/js/pages/profile/lookup.tsx), [developer page](resources/js/pages/profile/unclaimed.tsx), [GitHub lookups](app/Actions/CreateGitHubProfile.php), [mention count](app/Queries/UnclaimedProfileMentionCountQuery.php). ### Going live diff --git a/app/Http/Controllers/UnclaimedProfileController.php b/app/Http/Controllers/UnclaimedProfileController.php index 7af73204ba..6e9312aa7f 100644 --- a/app/Http/Controllers/UnclaimedProfileController.php +++ b/app/Http/Controllers/UnclaimedProfileController.php @@ -7,6 +7,7 @@ use App\Http\Requests\ShowUnclaimedProfileRequest; use App\Models\Profile; use App\Models\User; +use App\Queries\UnclaimedProfileMentionCountQuery; use App\Services\PageMetadata; use Illuminate\Container\Attributes\CurrentUser; use Illuminate\Http\RedirectResponse; @@ -19,9 +20,9 @@ /** * A developer looked up from GitHub who isn't on /dev/null yet has a page at their "@handle", with what GitHub * shows of them but where they are, for anyone with the link, but kept out of search engines, with how many members - * wait to follow them. Signing in as them makes it theirs. Like users' pages, it moves for good to the handle's own case. + * wait to follow them, and how many commits mention them. Signing in as them makes it theirs. Like users' pages, it moves for good to the handle's own case. */ - public function show(ShowUnclaimedProfileRequest $request, #[CurrentUser] ?User $currentUser, PageMetadata $metadata): RedirectResponse|Response + public function show(ShowUnclaimedProfileRequest $request, #[CurrentUser] ?User $currentUser, PageMetadata $metadata, UnclaimedProfileMentionCountQuery $mentions): RedirectResponse|Response { $profile = $request->profile(); assert($profile instanceof Profile); @@ -37,6 +38,8 @@ public function show(ShowUnclaimedProfileRequest $request, #[CurrentUser] ?User return Inertia::render('profile/unclaimed', [ 'profile' => $profile->only(['id', 'handle', 'name', 'avatar_url', 'bio']), + // Counting reads through the commits, so the page doesn't wait for it... + 'mentionCount' => Inertia::defer(fn (): int => $mentions->get($profile)), 'waitingCount' => fn (): int => $waiting->clone()->count(), 'isWaiting' => fn (): bool => $currentUser instanceof User && $waiting->clone()->where('user_id', $currentUser->id)->exists(), // Who follows whom is for members, so only they see who is waiting, among the people they follow... diff --git a/app/Queries/UnclaimedProfileMentionCountQuery.php b/app/Queries/UnclaimedProfileMentionCountQuery.php new file mode 100644 index 0000000000..f909f64b39 --- /dev/null +++ b/app/Queries/UnclaimedProfileMentionCountQuery.php @@ -0,0 +1,41 @@ +handle); + + return (int) Cache::remember("unclaimed-profile-mentions:{$handle}", self::CACHE_SECONDS, fn (): int => Commit::query() + ->approved() + ->where('body', 'ilike', "%@{$handle}%") + ->select(['id', 'body']) + ->lazyById(500) + ->filter(fn (Commit $commit): bool => in_array($handle, $this->mentions->handles($commit->body), true)) + ->count()); + } +} diff --git a/resources/js/pages/profile/unclaimed.tsx b/resources/js/pages/profile/unclaimed.tsx index fc86284749..37735b5429 100644 --- a/resources/js/pages/profile/unclaimed.tsx +++ b/resources/js/pages/profile/unclaimed.tsx @@ -1,7 +1,8 @@ -import { Head, router, usePage } from '@inertiajs/react'; -import { Clock } from 'lucide-react'; +import { Head, Link, router, usePage } from '@inertiajs/react'; +import { AtSign, Clock } from 'lucide-react'; import { useState } from 'react'; import PendingFollowController from '@/actions/App/Http/Controllers/PendingFollowController'; +import SearchController from '@/actions/App/Http/Controllers/SearchController'; import { show } from '@/actions/App/Http/Controllers/UserController'; import { BioText } from '@/components/bio-text'; import { useFollowHover } from '@/components/follow-button'; @@ -25,15 +26,18 @@ type UnclaimedProfile = { /** * A developer looked up from GitHub who isn't on /dev/null yet. Signing in as them makes the page theirs. Where they - * are is left out, even when GitHub shows it: they never chose to share it here. + * are is left out, even when GitHub shows it: they never chose to share it here. So are the commits that mention them, + * which they can't answer: the page only counts them, and links to a search for "@handle". */ export default function UnclaimedProfile({ profile, + mentionCount, waitingCount, isWaiting, waitingYouFollow, }: { profile: UnclaimedProfile; + mentionCount?: number; waitingCount: number; isWaiting: boolean; waitingYouFollow: Pick[]; @@ -114,6 +118,28 @@ export default function UnclaimedProfile({ github.com/{profile.handle} + {mentionCount !== undefined && mentionCount > 0 && ( +
  • + + + + {formatCount(mentionCount)} + {' '} + {mentionCount === 1 + ? 'commit mentions them' + : 'commits mention them'} + +
  • + )} {shownWaitingCount > 0 && ( diff --git a/tests/Feature/Controllers/UnclaimedProfileControllerTest.php b/tests/Feature/Controllers/UnclaimedProfileControllerTest.php index be3efd30e9..5795931b7f 100644 --- a/tests/Feature/Controllers/UnclaimedProfileControllerTest.php +++ b/tests/Feature/Controllers/UnclaimedProfileControllerTest.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use App\Models\Commit; use App\Models\Profile; use App\Models\User; use Illuminate\Support\Facades\DB; @@ -80,3 +81,17 @@ ->where('isWaiting', true) ->where('waitingYouFollow', [$followed->only(['id', 'handle', 'name', 'avatar_url'])])); }); + +it('counts the approved commits that mention them, but not mentions in code or of a longer handle', function (): void { + Profile::factory()->create(['handle' => 'octocat']); + Commit::factory()->create(['body' => 'Thanks @octocat!']); + Commit::factory()->create(['body' => 'Paired with @OctoCat and @hubot today']); + Commit::factory()->create(['body' => 'Found @octocat-fan in the wild']); + Commit::factory()->create(['body' => 'Use `@octocat` in your config']); + Commit::factory()->pending()->create(['body' => 'Waiting on @octocat']); + + $this->get('/@octocat') + ->assertInertia(fn ($page) => $page + ->missing('mentionCount') + ->loadDeferredProps(fn ($reload) => $reload->where('mentionCount', 2))); +}); From 66f9527a9cbf7fdd557b84fdeb529b8596367c73 Mon Sep 17 00:00:00 2001 From: Kjell Kind Date: Thu, 12 Nov 2026 12:17:40 +0100 Subject: [PATCH 2/2] fix: show the mention count without linking to search Guests can't open search, and search matches by meaning rather than by the handle, so the link didn't lead to the commits that mention them. Co-Authored-By: Claude Opus 5.5 --- KNOWLEDGE_BASE.md | 2 +- resources/js/pages/profile/unclaimed.tsx | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/KNOWLEDGE_BASE.md b/KNOWLEDGE_BASE.md index c43513bd5f..fbbb5efac0 100644 --- a/KNOWLEDGE_BASE.md +++ b/KNOWLEDGE_BASE.md @@ -149,7 +149,7 @@ A developer who isn't here yet gets a page with their GitHub avatar, name, handl Its page shows how many members are waiting to follow them: the members who followed them on GitHub when they were looked up, and the ones who clicked **Follow** on their page, which then reads **Waiting** and can be clicked again to stop waiting. Members also see the people they follow among them. When the developer signs up, everyone waiting follows them, and their notifications show those follows like any others. Who you wait to follow is in your data export, and goes when you delete your account. If you delete your account, your page doesn't come back as one of these, until you sign in again. -Its page also says how many commits mention them, like **12 commits mention them**, counting approved commits that mention `@handle` outside code, refreshed within the hour. The commits themselves aren't shown there, since they can't answer what's said about them: the count links to search with `@handle` filled in, for members. +Its page also says how many commits mention them, like **12 commits mention them**, counting approved commits that mention `@handle` outside code, refreshed within the hour. The commits themselves aren't shown or linked, since they can't answer what's said about them. Sources: [looking handles up](app/Http/Controllers/ProfileLookupController.php), [lookup page](resources/js/pages/profile/lookup.tsx), [developer page](resources/js/pages/profile/unclaimed.tsx), [GitHub lookups](app/Actions/CreateGitHubProfile.php), [mention count](app/Queries/UnclaimedProfileMentionCountQuery.php). diff --git a/resources/js/pages/profile/unclaimed.tsx b/resources/js/pages/profile/unclaimed.tsx index 37735b5429..e76ac8b016 100644 --- a/resources/js/pages/profile/unclaimed.tsx +++ b/resources/js/pages/profile/unclaimed.tsx @@ -1,8 +1,7 @@ -import { Head, Link, router, usePage } from '@inertiajs/react'; +import { Head, router, usePage } from '@inertiajs/react'; import { AtSign, Clock } from 'lucide-react'; import { useState } from 'react'; import PendingFollowController from '@/actions/App/Http/Controllers/PendingFollowController'; -import SearchController from '@/actions/App/Http/Controllers/SearchController'; import { show } from '@/actions/App/Http/Controllers/UserController'; import { BioText } from '@/components/bio-text'; import { useFollowHover } from '@/components/follow-button'; @@ -27,7 +26,7 @@ type UnclaimedProfile = { /** * A developer looked up from GitHub who isn't on /dev/null yet. Signing in as them makes the page theirs. Where they * are is left out, even when GitHub shows it: they never chose to share it here. So are the commits that mention them, - * which they can't answer: the page only counts them, and links to a search for "@handle". + * which they can't answer: the page only counts them. Search wouldn't list them either, since it matches by meaning. */ export default function UnclaimedProfile({ profile, @@ -121,15 +120,9 @@ export default function UnclaimedProfile({ {mentionCount !== undefined && mentionCount > 0 && (
  • - + {formatCount(mentionCount)} @@ -137,7 +130,7 @@ export default function UnclaimedProfile({ {mentionCount === 1 ? 'commit mentions them' : 'commits mention them'} - +
  • )}