Show navigation
Achievement Rarity
The gallery at /achievements shows each achievement's category, points, description, progress and unlock date (achievements). What it cannot say is whether an unlock is special: "First post" and a hidden clicker milestone look the same once earned. Steam's answer is the global achievement percentage — the share of a game's players who have each achievement, listed from most common to rarest — and it is the number people quote when they show an achievement off.
What it adds
- One grouped read.
achievement.readAchievementRaritiesreturns, per achievement, the count of users with a non-nullunlockedAtover the count of users, in oneGROUP BY achievementIdoveruserAchievementsplus onecount()overusers— the same shape asreadPointsLeaderboard's aggregate, and cheap enough to run on the page's load with no stored counter to keep in step. - On the card, under the points: "n% of users", with a Rare mark in the warning colour under a threshold named as a constant beside the other achievement constants. A hidden achievement a viewer has not unlocked shows its rarity too, as Steam does — it says how hard it is without saying what it is.
- Sort. The gallery gains a sort — Category (today's grouping, the default) and Rarest first.
- The leaderboard is unchanged: points already weight hard achievements, and rarity is a per-achievement fact.
The percentage is over every registered user, not over users of the product the achievement belongs to; a per-product denominator needs a notion of "has used the clicker" the schema does not keep, and a whole-platform share is still an honest reading of rarity here.
What is deliberately not in it
- No stored rarity column. A count over an indexed table on a page view is cheaper than a counter every unlock has to maintain transactionally.
- No rarity in the unlock toast. The toast fires inside the mutation that unlocked it; adding a count to that path puts an aggregate on every trigger.
Key files
| File | Role after the change |
|---|---|
apps/web/server/trpc/routers/achievement.ts | gains readAchievementRarities |
apps/web/app/components/Achievement/GridItem.vue | the percentage and the Rare mark on the card |
apps/web/app/components/Achievement/List.vue | the Category / Rarest first sort |
Sources
- Steamworks — Stats and achievements — global achievement statistics: the percentage of a game's players with each achievement, ordered common to rarest, and hidden achievements kept off a profile until earned.
Scroll to top