generated from nhcarrigan/template
feat: implement comprehensive achievement system with 62 achievements
Adds a complete achievement system with gamification features across all user interactions. **Database & Types:** - Add UserAchievement model to track user progress and earned achievements - Add achievement-related fields to User model (achievementPoints, currentStreak, lastStreakCheck) - Add ACHIEVEMENT_UNLOCKED audit action type - Define 62 achievements as TypeScript constants across 5 categories **Achievement Categories:** - Suggestions (15): First suggestion through ultimate curator milestones - Likes (12): First like through legendary fan milestones - Comments (12): First comment through review legend milestones - Engagement (15): Login streaks and total activity tracking - Reports (8): Valid reports and accuracy tracking **Backend Implementation:** - Create AchievementService with comprehensive checking logic - Add achievement route with 6 API endpoints - Integrate achievement checking into all user interaction points: - Suggestions (create + accept) - Likes (toggle) - Comments (all 6 media types) - Login streaks - Reports (profile + comment) - Update UserService to include achievement points in profiles **Frontend Implementation:** - Create AchievementService for API communication - Create achievements page showing all 62 achievements with: - Category filtering (All, Suggestions, Likes, Comments, Engagement, Reports) - Tier-based styling (Bronze, Silver, Gold, Platinum, Diamond) - Progress indicators for in-progress achievements - Earned date display for completed achievements - Add "Recent Achievements" section to user profiles - Add "🏆 Achievements" link to header navigation - Only show "View All" link on own profile **Technical Features:** - Real-time achievement checking on user actions - Progress tracking to avoid recalculation - Points system for gamification - Tier-based gradient styling - Leaderboard-ready architecture Resolves #48 Co-Authored-By: Hikari <hikari@nhcarrigan.com>
This commit is contained in:
@@ -207,6 +207,9 @@ model User {
|
||||
isVip Boolean @default(false)
|
||||
isMod Boolean @default(false)
|
||||
isStaff Boolean @default(false)
|
||||
achievementPoints Int @default(0)
|
||||
currentStreak Int @default(0)
|
||||
lastStreakCheck DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
comments Comment[]
|
||||
@@ -218,6 +221,7 @@ model User {
|
||||
reportsReviewed ProfileReport[] @relation("Reviewer")
|
||||
commentReportsMade CommentReport[] @relation("CommentReporter")
|
||||
commentReportsReviewed CommentReport[] @relation("CommentReviewer")
|
||||
userAchievements UserAchievement[]
|
||||
|
||||
@@index([slug], map: "User_slug_key")
|
||||
}
|
||||
@@ -276,6 +280,7 @@ enum AuditAction {
|
||||
RATE_LIMIT_EXCEEDED
|
||||
CSRF_VALIDATION_FAILED
|
||||
UNAUTHORIZED_ACCESS
|
||||
ACHIEVEMENT_UNLOCKED
|
||||
}
|
||||
|
||||
enum AuditCategory {
|
||||
@@ -400,3 +405,20 @@ model CommentReport {
|
||||
@@index([reporterId])
|
||||
@@index([status])
|
||||
}
|
||||
|
||||
model UserAchievement {
|
||||
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||
userId String @db.ObjectId
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
achievementKey String
|
||||
progress Int @default(0)
|
||||
earned Boolean @default(false)
|
||||
earnedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([userId, achievementKey])
|
||||
@@index([userId])
|
||||
@@index([achievementKey])
|
||||
@@index([earned])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user