fix(badge): do not award a tiered badge below the tier already held - #1632
Open
rstrzelecki-inne-projekty wants to merge 1 commit into
Open
rstrzelecki-inne-projekty wants to merge 1 commit into
rstrzelecki-inne-projekty wants to merge 1 commit into
Conversation
ReachAnswerAcceptedAmount awards every badge whose threshold the user has passed. For single award badges that form a ladder this reads as a demotion: a user who was granted the top badge by an administrator receives the lowest one the moment their first answer is accepted, congratulations dialog included. Crossing several thresholds at once grants the whole ladder in one go as well. Single award badges behind this handler now yield only the highest tier reached, and only when that tier is above the one the user already holds. Multi award badges, which every post can earn on its own, are untouched. Unit tests cover picking the tier, the tier already held, and the split between single and multi award badges.
rstrzelecki-inne-projekty
pushed a commit
to rstrzelecki-inne-projekty/answer
that referenced
this pull request
Sep 22, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
ReachAnswerAcceptedAmountawards every badge whoseamountthreshold the user has passed. For single award badges that form a ladder (each one marks a level reached), that produces two odd results:We hit the first one on a community where the ladder is a set of ranks: an account holding the rank for 80 accepted answers was awarded the rank for 1 as soon as an answer of theirs was accepted.
Change
For the single award badges behind this handler, only the highest tier reached is awarded, and only when that tier is above the one the user already holds. Multi award badges — the ones every post can earn on its own, such as the answer vote badges — keep the previous behaviour, so nothing changes for the default
nice_answer/good_answer/great_answerset.The tier picking and the "tier already held" lookup are separate helpers, so they can be tested without a database.
Tests
internal/repo/badge/badge_event_rule_test.gocovers picking the highest tier reached, ignoring a tier below the one already held, not awarding the top tier twice, and the split between single and multi award badges.go test ./internal/...passes.