AchievementRepository
Component Detail
Data Layer
medium complexity
backend
0
Dependencies
0
Dependents
1
Entities
0
Integrations
Description
Data access layer responsible for persisting earned badges and milestone rule definitions. It exposes CRUD operations for badge awards and provides aggregate queries used by AchievementService to determine current unlock status. All writes are idempotent to prevent duplicate awards from retry scenarios.
achievement-repository
Sources & reasoning
Statusbadges are explicitly named alongside the Wrapped concept in workshop output at line 76. The priority matrix (line 149) places the gamification cluster as NICE TO HAVE in Phase 3. The Phase 3 roadmap at line 353 groups badges with Wrapped and Advantage Calculator, normalizing to v1.1.
-
docs/source/likeperson.md · line 76Tre organisasjoner er inspirert av Spotify Wrapped og ønsker en funksjon som viser likepersonens bidrag over tid - «Din likepersonsårek». Målet er å gi frivillige stolthet og motivasjon, og gjøre usynlig innsats synlig. Også nevnt: «Årets koordinator
-
docs/source/likeperson.md · line 149| Gamification / Spotify Wrapped | ✓ | ✓ | - | ✓ | ✓ | NICE TO HAVE | 3 |
-
docs/source/likeperson.md · line 353Gamification / «Ditt likepersonsår» (Wrapped, badges, Advantage Calculator)
Responsibilities
- Store and retrieve badge award records keyed by mentor ID and badge ID
- Provide idempotent upsert for badge awards to handle duplicate evaluation runs
- Return the full ordered list of badge definitions with earned timestamps where applicable
- Support bulk queries returning badge counts per mentor for statistics pages
Interfaces
awardBadge(mentorId: string, badgeId: string, earnedAt: Date): Promise<void>
getBadgesByMentor(mentorId: string): Promise<BadgeAward[]>
hasBadge(mentorId: string, badgeId: string): Promise<boolean>
getBadgeDefinitions(): Promise<BadgeDefinition[]>
countBadgesByMentor(mentorId: string): Promise<number>