[Eva] Добавить удаление осиротевших достижений в init_achievements
This commit is contained in:
@@ -334,6 +334,20 @@ async def init_achievements():
|
|||||||
requirement_value = EXCLUDED.requirement_value
|
requirement_value = EXCLUDED.requirement_value
|
||||||
""", rows)
|
""", rows)
|
||||||
|
|
||||||
|
# 🔧 Удаление осиротевших достижений (которых больше нет в ACHIEVEMENTS_DATA)
|
||||||
|
await conn.execute("""
|
||||||
|
DELETE FROM user_achievements
|
||||||
|
WHERE achievement_id IN (
|
||||||
|
SELECT id FROM achievements
|
||||||
|
WHERE code NOT IN (SELECT unnest($1::text[]))
|
||||||
|
)
|
||||||
|
""", [a["code"] for a in ACHIEVEMENTS_DATA])
|
||||||
|
|
||||||
|
await conn.execute("""
|
||||||
|
DELETE FROM achievements
|
||||||
|
WHERE code NOT IN (SELECT unnest($1::text[]))
|
||||||
|
""", [a["code"] for a in ACHIEVEMENTS_DATA])
|
||||||
|
|
||||||
logger.info(f"[achievements] init: upserted {len(rows)} achievements")
|
logger.info(f"[achievements] init: upserted {len(rows)} achievements")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user