Skip to content

feat(badge): support repeatable badges - #598

Open
Armin1019 wants to merge 2 commits into
mainfrom
feat/1428-repeatable-badge
Open

Armin1019 wants to merge 2 commits into
mainfrom
feat/1428-repeatable-badge

Conversation

@Armin1019

Copy link
Copy Markdown
Collaborator

Summary

  • Badges get an IsRepeatable switch (default false, so every existing badge, including all Task Complete badges, stays one-time).
  • Awarding: a repeatable badge is awarded again on every match and keeps one UserBadge record per award. Non-repeatable badges keep the existing "only once" check.
  • The UserBadges (UserId, BadgeId) index is no longer unique (the auto-increment Id primary key already landed in AddIdToUserBadge #441).
  • The app still sees one entry per badge: the badge list returns each badge once at its first award, badge detail and equip use the first award, and a repeat copy never takes a display slot. Display slots are now counted per badge, not per record. No app change.
  • Migration AddIsRepeatableToBadge: adds Badges.IsRepeatable (bit, default 0), then drops and recreates IX_UserBadges_UserId_BadgeId without unique. No data is lost.

For reviewers

  • Down recreates the unique index, so it fails once any user holds two copies of a badge. Dedupe by hand before rolling back.
  • With the unique index gone, non-repeatable badges are only guarded in code. Two award runs at the same moment could both insert one (rare).
  • A repeatable Task Complete badge is awarded on every completion, so ticking a task on and off could farm it. No badge is repeatable yet; pick its rule with care before switching one on.
  • Staging cleanup (clearing user badges after deploy) is a manual SQL step for a tech lead. It is deliberately not in the migration, which also runs on Production.

Verified: dotnet test --filter "FullyQualifiedName~AwardNewBadgesToUserTests|FullyQualifiedName~GetUserBadgesTests|FullyQualifiedName~GetBadgeByIdTests|FullyQualifiedName~EquipBadgeTests" → 7 passed.

Release note

none

Status:

  • User-facing — announce it
  • Beta / partial — announce, but tagged as beta
  • Hidden in production (feature-flagged / not enabled for users) — don't announce
  • Internal only (refactor / infra / tests / CI / deps) — don't announce

@Armin1019 Armin1019 added the L4 Review level 4: AI review + 2 approvals, at least 1 tech lead label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

155 tests   155 ✅  12s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit f9b0afa.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor
Package Line Rate Branch Rate Complexity Health
BlotzTask 5% 37% 2983 ❌
BlotzTask 5% 37% 2983 ❌
Summary 5% (5522 / 120092) 37% (1190 / 3190) 5966 ❌

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L4 Review level 4: AI review + 2 approvals, at least 1 tech lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant