Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
118345f701 |
-40
@@ -898,46 +898,6 @@ async def init_db():
|
|||||||
""")
|
""")
|
||||||
logger.info("Added current_hints_used column to bubble_words_progress")
|
logger.info("Added current_hints_used column to bubble_words_progress")
|
||||||
|
|
||||||
# 🔧 НОВОЕ (14.10.2026): current_list_opened — серверный счётчик
|
|
||||||
# «показать слова» для текущего уровня пузырей. Medium — 1 раз.
|
|
||||||
col_exists = await conn.fetchval("""
|
|
||||||
SELECT 1 FROM information_schema.columns
|
|
||||||
WHERE table_name = 'bubble_words_progress' AND column_name = 'current_list_opened'
|
|
||||||
""")
|
|
||||||
if not col_exists:
|
|
||||||
await conn.execute("""
|
|
||||||
ALTER TABLE bubble_words_progress
|
|
||||||
ADD COLUMN current_list_opened INT DEFAULT 0
|
|
||||||
""")
|
|
||||||
logger.info("Added current_list_opened column to bubble_words_progress")
|
|
||||||
|
|
||||||
# 🔧 НОВОЕ (14.10.2026): current_level_words — состояние текущего
|
|
||||||
# уровня пузырей (слова + части + переводы). Нужно для подсказок,
|
|
||||||
# т.к. уровень генерируется на лету в /next и нигде не хранится.
|
|
||||||
col_exists = await conn.fetchval("""
|
|
||||||
SELECT 1 FROM information_schema.columns
|
|
||||||
WHERE table_name = 'bubble_words_progress' AND column_name = 'current_level_words'
|
|
||||||
""")
|
|
||||||
if not col_exists:
|
|
||||||
await conn.execute("""
|
|
||||||
ALTER TABLE bubble_words_progress
|
|
||||||
ADD COLUMN current_level_words JSONB DEFAULT '[]'::jsonb
|
|
||||||
""")
|
|
||||||
logger.info("Added current_level_words column to bubble_words_progress")
|
|
||||||
|
|
||||||
# 🔧 НОВОЕ (14.10.2026): hinted_words — какие слова уже получили
|
|
||||||
# подсказку «первая часть» (для «каждый раз разное слово»).
|
|
||||||
col_exists = await conn.fetchval("""
|
|
||||||
SELECT 1 FROM information_schema.columns
|
|
||||||
WHERE table_name = 'bubble_words_progress' AND column_name = 'hinted_words'
|
|
||||||
""")
|
|
||||||
if not col_exists:
|
|
||||||
await conn.execute("""
|
|
||||||
ALTER TABLE bubble_words_progress
|
|
||||||
ADD COLUMN hinted_words TEXT[] DEFAULT '{}'
|
|
||||||
""")
|
|
||||||
logger.info("Added hinted_words column to bubble_words_progress")
|
|
||||||
|
|
||||||
# ============ wrong_because_explanations ============
|
# ============ wrong_because_explanations ============
|
||||||
await conn.execute("""
|
await conn.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS wrong_because_explanations (
|
CREATE TABLE IF NOT EXISTS wrong_because_explanations (
|
||||||
|
|||||||
+37
-16
@@ -8,7 +8,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
router = APIRouter(prefix="/achievements", tags=["achievements"])
|
router = APIRouter(prefix="/achievements", tags=["achievements"])
|
||||||
|
|
||||||
# ============ Данные 55 достижений ============
|
# ============ Данные 52 достижений ============
|
||||||
ACHIEVEMENTS_DATA = [
|
ACHIEVEMENTS_DATA = [
|
||||||
# ===== Word Search (11) =====
|
# ===== Word Search (11) =====
|
||||||
{"code": "first_level", "category": "wordsearch", "icon": "🔰",
|
{"code": "first_level", "category": "wordsearch", "icon": "🔰",
|
||||||
@@ -245,7 +245,7 @@ ACHIEVEMENTS_DATA = [
|
|||||||
"desc_pl": "Ukończ poziom w mniej niż 30 sekund", "desc_ru": "Пройти уровень быстрее 30 секунд", "desc_uk": "Пройти рівень швидше 30 секунд", "desc_en": "Complete a level in under 30 seconds",
|
"desc_pl": "Ukończ poziom w mniej niż 30 sekund", "desc_ru": "Пройти уровень быстрее 30 секунд", "desc_uk": "Пройти рівень швидше 30 секунд", "desc_en": "Complete a level in under 30 seconds",
|
||||||
"type": "bubble_speed", "value": 30},
|
"type": "bubble_speed", "value": 30},
|
||||||
|
|
||||||
# ===== General (9) =====
|
# ===== General (15) =====
|
||||||
{"code": "score_1000", "category": "general", "icon": "🌟",
|
{"code": "score_1000", "category": "general", "icon": "🌟",
|
||||||
"name_pl": "Wschodząca gwiazda", "name_ru": "Восходящая звезда", "name_uk": "Висхідна зірка", "name_en": "Rising Star",
|
"name_pl": "Wschodząca gwiazda", "name_ru": "Восходящая звезда", "name_uk": "Висхідна зірка", "name_en": "Rising Star",
|
||||||
"desc_pl": "Zdobądź 1000 punktów", "desc_ru": "Набрать 1000 очков", "desc_uk": "Набрати 1000 балів", "desc_en": "Earn 1000 points",
|
"desc_pl": "Zdobądź 1000 punktów", "desc_ru": "Набрать 1000 очков", "desc_uk": "Набрати 1000 балів", "desc_en": "Earn 1000 points",
|
||||||
@@ -291,7 +291,42 @@ ACHIEVEMENTS_DATA = [
|
|||||||
"desc_pl": "Zmień język interfejsu", "desc_ru": "Сменить язык интерфейса", "desc_uk": "Змінити мову інтерфейсу", "desc_en": "Change interface language",
|
"desc_pl": "Zmień język interfejsu", "desc_ru": "Сменить язык интерфейса", "desc_uk": "Змінити мову інтерфейсу", "desc_en": "Change interface language",
|
||||||
"type": "language_changed", "value": 1},
|
"type": "language_changed", "value": 1},
|
||||||
|
|
||||||
|
# 🔧 ИСПРАВЛЕНО: Заменено достижение "Открой Грамматику" на "Открой меню учителя"
|
||||||
|
{"code": "open_teacher_menu", "category": "general", "icon": "🎓",
|
||||||
|
"name_pl": "Uczeń", "name_ru": "Ученик", "name_uk": "Учень", "name_en": "Student",
|
||||||
|
"desc_pl": "Otwórz menu nauczyciela", "desc_ru": "Открыть меню учителя", "desc_uk": "Відкрити меню вчителя", "desc_en": "Open the teacher menu",
|
||||||
|
"type": "teacher_menu_opened", "value": 1},
|
||||||
|
|
||||||
|
{"code": "open_cheatsheets", "category": "general", "icon": "📝",
|
||||||
|
"name_pl": "Ciekawski", "name_ru": "Любознательный", "name_uk": "Допитливий", "name_en": "Curious",
|
||||||
|
"desc_pl": "Otwórz sekcję Ściągi", "desc_ru": "Открыть раздел Шпаргалки", "desc_uk": "Відкрити розділ Шпаргалки", "desc_en": "Open the Cheatsheets section",
|
||||||
|
"type": "cheatsheets_opened", "value": 1},
|
||||||
|
|
||||||
|
{"code": "open_pronunciation", "category": "general", "icon": "🔊",
|
||||||
|
"name_pl": "Słuchacz", "name_ru": "Слушатель", "name_uk": "Слухач", "name_en": "Listener",
|
||||||
|
"desc_pl": "Otwórz sekcję Wymowa", "desc_ru": "Открыть раздел Произношение", "desc_uk": "Відкрити розділ Вимова", "desc_en": "Open the Pronunciation section",
|
||||||
|
"type": "pronunciation_opened", "value": 1},
|
||||||
|
|
||||||
|
{"code": "open_ai_assistant", "category": "general", "icon": "🤖",
|
||||||
|
"name_pl": "Asystent AI", "name_ru": "AI-помощник", "name_uk": "AI-помічник", "name_en": "AI Assistant",
|
||||||
|
"desc_pl": "Otwórz Asystenta AI", "desc_ru": "Открыть AI-помощника", "desc_uk": "Відкрити AI-помічника", "desc_en": "Open the AI Assistant",
|
||||||
|
"type": "ai_assistant_opened", "value": 1},
|
||||||
|
|
||||||
|
{"code": "open_alphabet", "category": "general", "icon": "🔤",
|
||||||
|
"name_pl": "Alfabetysta", "name_ru": "Алфавитист", "name_uk": "Алфавітист", "name_en": "Alphabetist",
|
||||||
|
"desc_pl": "Otwórz sekcję Alfabet", "desc_ru": "Открыть раздел Алфавит", "desc_uk": "Відкрити розділ Алфавіт", "desc_en": "Open the Alphabet section",
|
||||||
|
"type": "alphabet_opened", "value": 1},
|
||||||
|
|
||||||
|
{"code": "open_rules", "category": "general", "icon": "📐",
|
||||||
|
"name_pl": "Gramatyk", "name_ru": "Грамматик", "name_uk": "Граматик", "name_en": "Grammarian",
|
||||||
|
"desc_pl": "Otwórz sekcję Zasady", "desc_ru": "Открыть раздел Правила", "desc_uk": "Відкрити розділ Правила", "desc_en": "Open the Rules section",
|
||||||
|
"type": "rules_opened", "value": 1},
|
||||||
|
|
||||||
|
# 🔧 НОВОЕ: Достижение за открытие Прогресса
|
||||||
|
{"code": "open_progress", "category": "general", "icon": "📊",
|
||||||
|
"name_pl": "Planista", "name_ru": "Планировщик", "name_uk": "Планувальник", "name_en": "Planner",
|
||||||
|
"desc_pl": "Otwórz sekcję Postęp", "desc_ru": "Открыть раздел Прогресс", "desc_uk": "Відкрити розділ Прогрес", "desc_en": "Open the Progress section",
|
||||||
|
"type": "progress_opened", "value": 1},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -334,20 +369,6 @@ 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")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+16
-182
@@ -1,6 +1,5 @@
|
|||||||
import random
|
import random
|
||||||
import hashlib # 🔧 НОВОЕ: импорт hashlib для стабильного хэширования
|
import hashlib # 🔧 НОВОЕ: импорт hashlib для стабильного хэширования
|
||||||
import json
|
|
||||||
from fastapi import APIRouter, Request, HTTPException
|
from fastapi import APIRouter, Request, HTTPException
|
||||||
from auth import require_auth
|
from auth import require_auth
|
||||||
from database import get_pool
|
from database import get_pool
|
||||||
@@ -101,7 +100,7 @@ async def get_next_bubble_level(request: Request):
|
|||||||
pool = await get_pool()
|
pool = await get_pool()
|
||||||
async with pool.acquire() as conn:
|
async with pool.acquire() as conn:
|
||||||
user = await conn.fetchrow(
|
user = await conn.fetchrow(
|
||||||
"SELECT app_language, current_level, difficulty FROM users WHERE telegram_id = $1", telegram_id
|
"SELECT app_language, current_level FROM users WHERE telegram_id = $1", telegram_id
|
||||||
)
|
)
|
||||||
if not user:
|
if not user:
|
||||||
raise HTTPException(401, "User not registered")
|
raise HTTPException(401, "User not registered")
|
||||||
@@ -115,9 +114,13 @@ async def get_next_bubble_level(request: Request):
|
|||||||
)
|
)
|
||||||
current_bubble_level = (progress["levels_completed"] if progress else 0) + 1
|
current_bubble_level = (progress["levels_completed"] if progress else 0) + 1
|
||||||
|
|
||||||
# Количество слов по сложности
|
# Прогрессия по количеству слов на уровне
|
||||||
difficulty = user["difficulty"] if "difficulty" in user.keys() else "medium"
|
if current_bubble_level <= 10:
|
||||||
num_words = {"easy": 3, "medium": 4, "hard": 5}.get(difficulty, 4)
|
num_words = random.choice([3, 4])
|
||||||
|
elif current_bubble_level <= 25:
|
||||||
|
num_words = random.choice([5, 6])
|
||||||
|
else:
|
||||||
|
num_words = random.choice([7, 8])
|
||||||
|
|
||||||
# 🔧 ФИКС (30.09.2026): csv_words_source —
|
# 🔧 ФИКС (30.09.2026): csv_words_source —
|
||||||
# источник слов переехал с level_words (старая схема level_id IS NULL)
|
# источник слов переехал с level_words (старая схема level_id IS NULL)
|
||||||
@@ -159,172 +162,10 @@ async def get_next_bubble_level(request: Request):
|
|||||||
|
|
||||||
random.shuffle(all_parts)
|
random.shuffle(all_parts)
|
||||||
|
|
||||||
# 🔧 НОВОЕ (14.10.2026): сохраняем состояние уровня для подсказок
|
|
||||||
# и сбрасываем счётчики подсказок/списка при новом уровне.
|
|
||||||
level_state = [
|
|
||||||
{
|
|
||||||
"word_pl": w["word_pl"],
|
|
||||||
"translation": w["translation"],
|
|
||||||
"parts": w["parts"],
|
|
||||||
}
|
|
||||||
for w in result_words
|
|
||||||
]
|
|
||||||
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, 0, 0, $2, 0, 0, $3::jsonb, '{}')
|
|
||||||
ON CONFLICT (user_id) DO UPDATE
|
|
||||||
SET current_hints_used = 0,
|
|
||||||
current_list_opened = 0,
|
|
||||||
current_level_words = $3::jsonb,
|
|
||||||
hinted_words = '{}'
|
|
||||||
""", telegram_id, current_level, json.dumps(level_state))
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"words": result_words,
|
"words": result_words,
|
||||||
"bubbles": all_parts,
|
"bubbles": all_parts,
|
||||||
"level": current_bubble_level,
|
"level": current_bubble_level,
|
||||||
"difficulty": user["difficulty"] or "medium",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/first-part-hint")
|
|
||||||
async def first_part_hint(request: Request):
|
|
||||||
"""Подсказка «первая часть слова» — возвращает первый пузырь одного из несобранных слов.
|
|
||||||
|
|
||||||
🔧 НОВОЕ (14.10.2026): аналог GET /hints/first-letter/{level_id} из филворда.
|
|
||||||
Лимит 3 подсказки, штраф −20 (учитывается в /complete через current_hints_used).
|
|
||||||
Hard — запрещено (400).
|
|
||||||
"""
|
|
||||||
telegram_id, _ = await require_auth(request)
|
|
||||||
body = await request.json()
|
|
||||||
found_words = set(body.get("found_words", []) or [])
|
|
||||||
|
|
||||||
pool = await get_pool()
|
|
||||||
async with pool.acquire() as conn:
|
|
||||||
user = await conn.fetchrow(
|
|
||||||
"SELECT difficulty FROM users WHERE telegram_id = $1", telegram_id
|
|
||||||
)
|
|
||||||
if not user:
|
|
||||||
raise HTTPException(401, "User not registered")
|
|
||||||
|
|
||||||
difficulty = user["difficulty"] or "medium"
|
|
||||||
if difficulty == "hard":
|
|
||||||
raise HTTPException(400, "Hints are disabled on Hard difficulty")
|
|
||||||
|
|
||||||
progress = await conn.fetchrow(
|
|
||||||
"SELECT current_hints_used, current_level_words, hinted_words "
|
|
||||||
"FROM bubble_words_progress WHERE user_id = $1",
|
|
||||||
telegram_id
|
|
||||||
)
|
|
||||||
if not progress:
|
|
||||||
raise HTTPException(404, "No active level")
|
|
||||||
|
|
||||||
hints_used = progress["current_hints_used"] or 0
|
|
||||||
if hints_used >= 3:
|
|
||||||
raise HTTPException(400, "All hints used")
|
|
||||||
|
|
||||||
raw = progress["current_level_words"]
|
|
||||||
if isinstance(raw, str):
|
|
||||||
level_words = json.loads(raw) if raw else []
|
|
||||||
else:
|
|
||||||
level_words = raw or []
|
|
||||||
|
|
||||||
raw_hinted = progress["hinted_words"]
|
|
||||||
if isinstance(raw_hinted, str):
|
|
||||||
hinted = set(json.loads(raw_hinted)) if raw_hinted else set()
|
|
||||||
else:
|
|
||||||
hinted = set(raw_hinted or [])
|
|
||||||
|
|
||||||
# Слова, которые ещё не собраны и которым ещё не давали подсказку
|
|
||||||
candidates = [
|
|
||||||
w for w in level_words
|
|
||||||
if w.get("word_pl") not in found_words and w.get("word_pl") not in hinted
|
|
||||||
]
|
|
||||||
|
|
||||||
if not candidates:
|
|
||||||
raise HTTPException(400, "All words already hinted")
|
|
||||||
|
|
||||||
chosen = random.choice(candidates)
|
|
||||||
word_pl = chosen["word_pl"]
|
|
||||||
parts = chosen.get("parts") or []
|
|
||||||
first_part = parts[0] if parts else word_pl
|
|
||||||
|
|
||||||
new_hints = hints_used + 1
|
|
||||||
new_hinted = sorted(hinted | {word_pl})
|
|
||||||
|
|
||||||
await conn.execute("""
|
|
||||||
UPDATE bubble_words_progress
|
|
||||||
SET current_hints_used = $2,
|
|
||||||
hinted_words = $3
|
|
||||||
WHERE user_id = $1
|
|
||||||
""", telegram_id, new_hints, new_hinted)
|
|
||||||
|
|
||||||
return {
|
|
||||||
"word_pl": word_pl,
|
|
||||||
"first_part": first_part,
|
|
||||||
"hints_used_total": new_hints,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/show-words")
|
|
||||||
async def show_words(request: Request):
|
|
||||||
"""Подсказка «показать слова» — возвращает все загаданные слова с переводами.
|
|
||||||
|
|
||||||
🔧 НОВОЕ (14.10.2026): аналог show-words из филворда.
|
|
||||||
Easy — без лимита. Medium — 1 раз (−20). Hard — запрещено (400).
|
|
||||||
"""
|
|
||||||
telegram_id, _ = await require_auth(request)
|
|
||||||
|
|
||||||
pool = await get_pool()
|
|
||||||
async with pool.acquire() as conn:
|
|
||||||
user = await conn.fetchrow(
|
|
||||||
"SELECT difficulty FROM users WHERE telegram_id = $1", telegram_id
|
|
||||||
)
|
|
||||||
if not user:
|
|
||||||
raise HTTPException(401, "User not registered")
|
|
||||||
|
|
||||||
difficulty = user["difficulty"] or "medium"
|
|
||||||
if difficulty == "hard":
|
|
||||||
raise HTTPException(400, "Word list is disabled on Hard difficulty")
|
|
||||||
|
|
||||||
progress = await conn.fetchrow(
|
|
||||||
"SELECT current_list_opened, current_level_words "
|
|
||||||
"FROM bubble_words_progress WHERE user_id = $1",
|
|
||||||
telegram_id
|
|
||||||
)
|
|
||||||
if not progress:
|
|
||||||
raise HTTPException(404, "No active level")
|
|
||||||
|
|
||||||
list_opened = progress["current_list_opened"] or 0
|
|
||||||
|
|
||||||
# Medium — список можно открыть только 1 раз
|
|
||||||
if difficulty == "medium" and list_opened >= 1:
|
|
||||||
raise HTTPException(400, "Word list already used on Medium difficulty")
|
|
||||||
|
|
||||||
raw = progress["current_level_words"]
|
|
||||||
if isinstance(raw, str):
|
|
||||||
level_words = json.loads(raw) if raw else []
|
|
||||||
else:
|
|
||||||
level_words = raw or []
|
|
||||||
|
|
||||||
words = [
|
|
||||||
{"word_pl": w.get("word_pl"), "translation": w.get("translation")}
|
|
||||||
for w in level_words
|
|
||||||
]
|
|
||||||
|
|
||||||
# Инкремент счётчика для Easy и Medium (Hard сюда не доходит)
|
|
||||||
new_list_opened = list_opened + 1
|
|
||||||
await conn.execute("""
|
|
||||||
UPDATE bubble_words_progress
|
|
||||||
SET current_list_opened = $2
|
|
||||||
WHERE user_id = $1
|
|
||||||
""", telegram_id, new_list_opened)
|
|
||||||
|
|
||||||
return {
|
|
||||||
"words": words,
|
|
||||||
"list_opened_total": new_list_opened,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -343,6 +184,7 @@ async def complete_bubble_level(request: Request):
|
|||||||
body = await request.json()
|
body = await request.json()
|
||||||
words_count = body.get("words_count", 3)
|
words_count = body.get("words_count", 3)
|
||||||
completion_time = body.get("completion_time")
|
completion_time = body.get("completion_time")
|
||||||
|
list_opened = bool(body.get("list_opened", False))
|
||||||
wrong_words = int(body.get("wrong_words", 0) or 0)
|
wrong_words = int(body.get("wrong_words", 0) or 0)
|
||||||
|
|
||||||
pool = await get_pool()
|
pool = await get_pool()
|
||||||
@@ -359,15 +201,12 @@ async def complete_bubble_level(request: Request):
|
|||||||
current_level = user["current_level"] or "A1"
|
current_level = user["current_level"] or "A1"
|
||||||
difficulty = user["difficulty"] or "medium"
|
difficulty = user["difficulty"] or "medium"
|
||||||
|
|
||||||
# Читаем серверные счётчики (не из body)
|
# Читаем серверный hints_used
|
||||||
progress = await conn.fetchrow(
|
hints_used = await conn.fetchval(
|
||||||
"SELECT current_hints_used, current_list_opened "
|
"SELECT current_hints_used FROM bubble_words_progress WHERE user_id = $1",
|
||||||
"FROM bubble_words_progress WHERE user_id = $1",
|
|
||||||
telegram_id
|
telegram_id
|
||||||
)
|
) or 0
|
||||||
hints_used = (progress["current_hints_used"] if progress else 0) or 0
|
|
||||||
hints_used = min(max(0, hints_used), 3)
|
hints_used = min(max(0, hints_used), 3)
|
||||||
list_opened = (progress["current_list_opened"] if progress else 0) or 0
|
|
||||||
|
|
||||||
# 🔧 НОВОЕ (14.10.2026): очки по формуле филворда.
|
# 🔧 НОВОЕ (14.10.2026): очки по формуле филворда.
|
||||||
# Hard — фикс 110. Easy/Medium — 100 − 20×hints − 20×list + bonus.
|
# Hard — фикс 110. Easy/Medium — 100 − 20×hints − 20×list + bonus.
|
||||||
@@ -390,18 +229,13 @@ async def complete_bubble_level(request: Request):
|
|||||||
score = xp_result["points"]
|
score = xp_result["points"]
|
||||||
|
|
||||||
await conn.execute("""
|
await conn.execute("""
|
||||||
INSERT INTO bubble_words_progress
|
INSERT INTO bubble_words_progress (user_id, levels_completed, total_score, level, current_hints_used)
|
||||||
(user_id, levels_completed, total_score, level,
|
VALUES ($1, 1, $2, $3, 0)
|
||||||
current_hints_used, current_list_opened, current_level_words, hinted_words)
|
|
||||||
VALUES ($1, 1, $2, $3, 0, 0, '[]'::jsonb, '{}')
|
|
||||||
ON CONFLICT (user_id) DO UPDATE
|
ON CONFLICT (user_id) DO UPDATE
|
||||||
SET levels_completed = bubble_words_progress.levels_completed + 1,
|
SET levels_completed = bubble_words_progress.levels_completed + 1,
|
||||||
total_score = bubble_words_progress.total_score + $2,
|
total_score = bubble_words_progress.total_score + $2,
|
||||||
level = $3,
|
level = $3,
|
||||||
current_hints_used = 0,
|
current_hints_used = 0
|
||||||
current_list_opened = 0,
|
|
||||||
current_level_words = '[]'::jsonb,
|
|
||||||
hinted_words = '{}'
|
|
||||||
""", telegram_id, score, current_level)
|
""", telegram_id, score, current_level)
|
||||||
|
|
||||||
# Данные для достижений
|
# Данные для достижений
|
||||||
|
|||||||
Reference in New Issue
Block a user