(Story #2486) Task: Manual / Non-Automated Achievement Sources#2515
Draft
herzog0 wants to merge 46 commits into
Draft
(Story #2486) Task: Manual / Non-Automated Achievement Sources#2515herzog0 wants to merge 46 commits into
herzog0 wants to merge 46 commits into
Conversation
Add two columns to the Review admin changelist so reviewers can see the associated review manager at a glance: - get_review_manager: the resolved CommitAuthor FK (sortable by name) - review_manager_raw: the raw imported string, useful when the FK hasn't been linked yet Extend search_fields so admins can find reviews by either the linked manager or the raw text, and prefetch the FK in get_queryset to avoid an N+1 on the changelist.
…anager' Wrap review_manager_raw in a display method so the column header is the explicit 'Scraped review manager' instead of the auto-derived 'Review manager raw'. The new label makes it clearer that the column shows the verbatim string scraped from boost.org's review-results page, not a curated value.
boost.org serves /doc/formal-reviews/review-results.html with `Content-Type: text/html` and no charset, so `requests` falls back to ISO-8859-1 per RFC 2616 even though the body is actually UTF-8. Every accented name in the scraped table was therefore being mojibake-decoded into the raw fields - e.g. "Joaquín M López Muñoz" turned into "JoaquÃn M López Muñoz" - which both polluted the admin's "Scraped review manager" column and broke the exact-match FK lookup against CommitAuthor.name. Override `response.encoding` to "utf-8" before reading `.text`. The next `import_reviews` run rewrites existing rows in place (their fingerprints survive the special-character normaliser in `_normalize`), so previously-corrupted rows heal automatically. Add a regression test that drives the importer with a UTF-8 body served under a charsetless / ISO-8859-1 default response and asserts the raw field stores the proper accented string, not the mojibake artefacts.
|
Important Review skippedDraft detected. 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:
✨ Finishing Touches🧪 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 |
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: #2486
Summary & Context
Implements the full Achievements & Badges system: a new
badges/Django app where every achievement a user earns is aUserAchievementrow (automatic or manual), and badge tiers (UserBadge) are derived state reconciled by a single recalculation service. Ingestion is batch-based (weekly backfill from historical Boost data) plus manual admin grants; users are emailed when they earn a badge (opt-in) and their earned badges show on the v3 profile page. Also reworks the review importer inversions/to scrape the new boost.org review-results page, which supplies the data for the Library Review badge.localhost:8000/admin/badges/; profile -localhost:8000/users/me/Changes
Badges app (new)
Achievement,UserAchievement(generic FK to the source record, soft invalidation with audit fields),Badge,BadgeTier(append-only, soft delete, one active tier per rank),UserBadge(soft revocation with audit fields and a cascade/manualrevocation_source)recalculate_badgesservice - the single writer ofUserBadgestate: idempotent, race-safe (get_or_create), awards, re-earns, and cascade-revokes from the count of valid achievements; manually revoked badges are never silently re-earned (a "Reinstate" admin action is the explicit undo)seed_cataloguehelper)backfill_achievementsandrecalculate_badgesmanagement commands with Celery task wrappers; backfill bulk-inserts idempotently and only recalculates pairs that actually gained rowssource_type/granted_by; invalidation and revocation require an audit note; tier choices are scoped to the selected badge server-side; changelist buttons queue backfill/recalculation on Celery (debounced via cache)Integration
release_tasksandupdate_commitsrun the backfill after imports; live per-row signals were deliberately dropped for bulk paths (achievements are batch, not real-time)users.Badgemodel andUser.badgesM2M (users/0022)Review importer (supports the reviewer badge)
import_reviewsscrapes the new boost.org review-results page (UTF-8 forced), deduplicates via a flexible multi-field fingerprint, and links submitters to usersRisks & Considerations
0006deletes the inflated per-version maintenance achievements, but existingUserBadgerows stay until a recalculation. After deploy, press "Recalculate badges" in the UserBadge admin (or wait for the weekly backfill to settle new grants).notify=False). Worth double-checking the preference default before the first production backfill.recalculate_badgesruns synchronously in theUserAchievementsignal - fine for manual admin volumes; bulk ingestion bypasses signals entirely (bulk_create).Screenshots
TBD