diff --git a/routers/bubblewords.py b/routers/bubblewords.py index 3b4fef4..a9789b5 100644 --- a/routers/bubblewords.py +++ b/routers/bubblewords.py @@ -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(