fix: prevent achievement points from being re-awarded on republish
All checks were successful
Build and Push Backend Image / build (push) Successful in 1m2s
All checks were successful
Build and Push Backend Image / build (push) Successful in 1m2s
Once an achievement is unlocked, preserve date_unlocked permanently instead of clearing it to null when the user drops below the threshold (e.g. on unpublish). This prevents the wasUnlocked check from returning false on republish, which was causing achievement points to be re-awarded on every publish/unpublish cycle. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -195,7 +195,9 @@ export async function checkAchievements(db: DB, userId: string, category?: strin
|
|||||||
.update(user_achievements)
|
.update(user_achievements)
|
||||||
.set({
|
.set({
|
||||||
progress,
|
progress,
|
||||||
date_unlocked: isUnlocked ? existing[0].date_unlocked || new Date() : null,
|
date_unlocked: isUnlocked
|
||||||
|
? (existing[0].date_unlocked ?? new Date())
|
||||||
|
: existing[0].date_unlocked,
|
||||||
})
|
})
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
|
|||||||
Reference in New Issue
Block a user