Ticket #2539 :: Task: Track documentation contributions and derive the Documenter achievement from them - #2641
Ticket #2539 :: Task: Track documentation contributions and derive the Documenter achievement from them #2641herzog0 wants to merge 19 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (20)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe pull request adds stable deduplication keys for automatic achievements, tracks documentation changes during Git imports, wires documentation commits to the Documenter badge, and centralizes review fingerprint generation. ChangesBadge deduplication and documentation sources
Review identity reuse
Estimated code review effort: 4 (Complex) | ~60 minutes Merge Risk: ⚪ Minimal · up to This change adds automatic documentation achievement tracking and related persistence updates; no actionable merge-blocking risk remains, so it is merge-ready after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant GitRepository
participant libraries.github
participant libraries.doc_paths
participant Commit
participant badges.sources
participant badges.services
participant UserAchievement
GitRepository->>libraries.github: Return git log --numstat output
libraries.github->>libraries.doc_paths: Count documentation files
libraries.doc_paths-->>libraries.github: Return documentation-file count
libraries.github->>Commit: Store docs_files_changed
badges.sources->>badges.services: Yield user, commit, and commit SHA
badges.services->>UserAchievement: Create or update keyed grant
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
27ed0df to
657de79
Compare
Issue: #2539
teo/badges-docsSummary & Context
Makes Documenter an automatic achievement. Nothing in the site recorded who wrote
documentation, so the badge could only be granted by hand. The commit importer already clones
every library repo, so asking git for per-file statistics in the same call costs one flag and no
extra API traffic. Each commit now carries a count of the documentation files it touched, and the
achievement counts commits with a non-zero count.
Getting there needed one fix first. An automatic grant identified its evidence by the row it
pointed at, and commit row ids are not stable: the importer deletes and re-creates them, and the
same commit is stored once per release range covering it. So grants were being orphaned and counts
inflated. Grants now carry the source's own id instead (a commit sha, a library key, a review
fingerprint). That part is invisible on screen but is the reason the new source can be trusted.
Changes
dedup_infocolumn and are matched on it instead of on a row id.Reviewcan produce its own dedup fingerprint, which the import command used to keep private.Commit.no key, so a reconcile replaces them rather than adopting them. Nothing is in production; staging
and QA should have their badge tables emptied and rebuilt. I (Teo) will be doing that.
like a regression.
every grant it fed. Cheap to change now, expensive after launch.
again, so doc work predating this shows as zero until then.
it safe for achievements; whether the button should stop doing that is an open question on the
ticket.
doc path. Those two should be settled together before a production backfill.
Screenshots
n/a - no UI. The badge already renders wherever badges render.
Peer-review testing steps
Setup:
just load_production_data,just migrate,docker compose up.The rules. In
just manage shell:A real import.
just manage import_commits --key mp11, then:Spot-check one sha against the repo:
git show --numstat <sha>and count the doc paths yourself.Backfill.
just manage backfill_achievements --source documentation, then run it asecond time. The second run must report
added 0.Pk churn is a non-event. Note the code-commits and documentation grant counts, then
just manage import_commits --key mp11 --cleanand backfill both sources again. Countsunchanged, and no grant left pointing at a deleted row:
Reconcile.
just manage reconcile_achievements --dry-run. Over freshly backfilleddata every source reports
added 0, removed 0.QA notes
Everything here is doable from the admin at
/admin/. You need a member who has writtendocumentation in a Boost library and whose commit email is linked to their account; ask the
developer to point you at one, or to run the import for a library you can then use.
Documenter is automatic now. Open Badges. The Documenter row's Automatic column
used to say no and now says yes. Only Regular and Publisher still say no.
It appears as a source you can choose. Open User achievements and press Backfill
achievements. Documentation is now in the source list. Pick it and run it. The status
finishes in place, no reload needed.
Grants arrived, and say where from. Still on User achievements, filter Achievement to
Documentation. Each row's Source column links to the commit that earned it; click one and
check the commit message looks like documentation work. Open a row: there is a read-only
Dedup info field showing the commit's id from git. Nothing except Grant notes should be
editable.
The badge was awarded. Open User badges. The members from step 3 hold Documenter at
whichever tier their count reaches. Click a member's name for their per-member page: it shows
the valid grant count and how many more are needed for the next tier.
Running it twice changes nothing. Press Backfill achievements on Documentation again,
then open Achievement sync runs. Two documentation rows, the second with Added 0, both
naming you under Triggered by. This is the most important check in this list: it is what
stops the weekly job doubling everyone's count.
Search by commit id. Copy the Dedup info value from a grant in step 3 and paste it into
the search box on User achievements. It finds that grant. This did not work before.
The profile still looks right. Log in as (or impersonate) a member holding Documenter and
open their profile. The badge renders with the others. Check light and dark mode, and check that
a member with Hide badges ticked in their preferences still shows none.
Manual grants are untouched. Grant Documentation to someone by hand with a note, then run
Backfill achievements on Documentation again. The manual grant is still there, still shows
your note, and still names you as the granting admin.
If you see zero grants after step 2, that is not necessarily a bug: the achievement only credits
commits whose author is linked to a member account. Ask the developer to confirm any exist on your
database before treating it as a failure.
Self-review Checklist
Backend
pre-commit run -acleanthe base branch: 11 environment-related (a quoted
AWS_REGIONin the local env file, andpath-matcher tests that reach S3), plus one Django connection-pool teardown error in a
timezone test.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation