[Eva] Ева, привет! Задача — собрать анамнез по #46
+24
-4
@@ -389,11 +389,16 @@ async def complete_bubble_level(request: Request):
|
||||
xp_result = await award_xp(conn, telegram_id, "bubbles", points)
|
||||
score = xp_result["points"]
|
||||
|
||||
# 🔧 НОВОЕ (15.10.2026): флаги для накопления серий.
|
||||
no_hints_clean = 1 if (hints_used == 0 and not list_opened) else 0
|
||||
perfect_clean = 1 if (hints_used == 0 and not list_opened and wrong_words == 0) else 0
|
||||
|
||||
await conn.execute("""
|
||||
INSERT INTO bubble_words_progress
|
||||
(user_id, levels_completed, total_score, level,
|
||||
current_hints_used, current_list_opened, current_level_words, hinted_words)
|
||||
VALUES ($1, 1, $2, $3, 0, 0, '[]'::jsonb, '{}')
|
||||
current_hints_used, current_list_opened, current_level_words, hinted_words,
|
||||
words_collected, no_hints_streak, perfect_streak)
|
||||
VALUES ($1, 1, $2, $3, 0, 0, '[]'::jsonb, '{}', $4, $5, $6)
|
||||
ON CONFLICT (user_id) DO UPDATE
|
||||
SET levels_completed = bubble_words_progress.levels_completed + 1,
|
||||
total_score = bubble_words_progress.total_score + $2,
|
||||
@@ -401,8 +406,23 @@ async def complete_bubble_level(request: Request):
|
||||
current_hints_used = 0,
|
||||
current_list_opened = 0,
|
||||
current_level_words = '[]'::jsonb,
|
||||
hinted_words = '{}'
|
||||
""", telegram_id, score, current_level)
|
||||
hinted_words = '{}',
|
||||
words_collected = COALESCE(bubble_words_progress.words_collected, 0) + $4,
|
||||
no_hints_streak = CASE WHEN $5 = 1
|
||||
THEN COALESCE(bubble_words_progress.no_hints_streak, 0) + 1 ELSE 0 END,
|
||||
perfect_streak = CASE WHEN $6 = 1
|
||||
THEN COALESCE(bubble_words_progress.perfect_streak, 0) + 1 ELSE 0 END
|
||||
""", telegram_id, score, current_level, words_count, no_hints_clean, perfect_clean)
|
||||
|
||||
# 🔧 НОВОЕ (15.10.2026): читаем актуальные счётчики для проверки достижений.
|
||||
stats = await conn.fetchrow("""
|
||||
SELECT words_collected, no_hints_streak, perfect_streak, total_score
|
||||
FROM bubble_words_progress WHERE user_id = $1
|
||||
""", telegram_id)
|
||||
words_collected = stats["words_collected"] or 0
|
||||
no_hints_streak = stats["no_hints_streak"] or 0
|
||||
perfect_streak = stats["perfect_streak"] or 0
|
||||
bubble_total_score = stats["total_score"] or 0
|
||||
|
||||
# Данные для достижений
|
||||
total_levels = await conn.fetchval(
|
||||
|
||||
Reference in New Issue
Block a user