🧪 Smoke-test: 10/10 PASSED — волна 1 + волна 2
Покрытие (10 сценариев): - pronunciation_pool_stress — утечка пула - hints_db_increment — списание подсказок - game_complete_level_full_flow — идемпотентность + score - wordquiz_correct_answer — total_score растёт - wordquiz_wrong_answer — current_mistakes растёт - bubblewords_complete_flow — levels + score - sentences_check_wrong — неверный ответ не начисляет - typing_progress_flow — typing_progress записан - users_set_language — app_language меняется - achievements_track_login — daily_logins растёт Результат: 10/10 PASSED за 0.79s. Робот подтверждает: большинство находок AI-ревью по этим разделам — галлюцинации. Инвентаризация: - scripts/dump_inventory.py — собирает эндпоинты + схему - endpoints_inventory.md — 105 эндпоинтов - database_schema.md — 40 таблиц
This commit is contained in:
@@ -0,0 +1,557 @@
|
|||||||
|
# 🗄 Схема базы данных
|
||||||
|
|
||||||
|
## achievements
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('achievements_id_seq'::regclass) |
|
||||||
|
| code | text | NO | |
|
||||||
|
| category | text | YES | 'general'::text |
|
||||||
|
| name_pl | text | NO | |
|
||||||
|
| name_ru | text | NO | |
|
||||||
|
| name_uk | text | NO | |
|
||||||
|
| name_en | text | NO | |
|
||||||
|
| description_pl | text | YES | ''::text |
|
||||||
|
| description_ru | text | YES | ''::text |
|
||||||
|
| description_uk | text | YES | ''::text |
|
||||||
|
| description_en | text | YES | ''::text |
|
||||||
|
| icon | text | YES | '🏆'::text |
|
||||||
|
| requirement_type | text | NO | |
|
||||||
|
| requirement_value | integer | YES | 0 |
|
||||||
|
|
||||||
|
## ai_user_context
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| current_level | character varying | YES | |
|
||||||
|
| completed_topics | integer | YES | 0 |
|
||||||
|
| completed_lessons | integer | YES | 0 |
|
||||||
|
| overall_mastery | numeric | YES | |
|
||||||
|
| strong_skills | jsonb | YES | '[]'::jsonb |
|
||||||
|
| weak_skills | jsonb | YES | '[]'::jsonb |
|
||||||
|
| uncertain_skills | jsonb | YES | '[]'::jsonb |
|
||||||
|
| recurring_errors | jsonb | YES | '[]'::jsonb |
|
||||||
|
| recommended_topics | jsonb | YES | '[]'::jsonb |
|
||||||
|
| recommended_lessons | jsonb | YES | '[]'::jsonb |
|
||||||
|
| last_analysis_at | timestamp without time zone | YES | |
|
||||||
|
| analytics_enabled | boolean | YES | false |
|
||||||
|
| level_topics_total | integer | YES | 0 |
|
||||||
|
| level_completion_percent | numeric | YES | 0 |
|
||||||
|
|
||||||
|
## bubble_words_progress
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| levels_completed | integer | YES | 0 |
|
||||||
|
| total_score | integer | YES | 0 |
|
||||||
|
| recent_words | ARRAY | YES | '{}'::text[] |
|
||||||
|
| level | text | YES | 'A1'::text |
|
||||||
|
| current_hints_used | integer | YES | 0 |
|
||||||
|
|
||||||
|
## chat_history
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('chat_history_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | YES | |
|
||||||
|
| message | text | NO | |
|
||||||
|
| is_user | boolean | YES | true |
|
||||||
|
| created_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## chat_usage
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('chat_usage_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | YES | |
|
||||||
|
| usage_date | date | YES | CURRENT_DATE |
|
||||||
|
| message_count | integer | YES | 0 |
|
||||||
|
|
||||||
|
## daily_logins
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| login_date | date | NO | CURRENT_DATE |
|
||||||
|
|
||||||
|
## daily_phrases
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('daily_phrases_id_seq'::regclass) |
|
||||||
|
| phrase_date | date | NO | |
|
||||||
|
| phrase_pl | text | NO | |
|
||||||
|
| translations | jsonb | NO | '{}'::jsonb |
|
||||||
|
| grammar_breakdowns | jsonb | NO | '{}'::jsonb |
|
||||||
|
| created_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## feed_attachments
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('feed_attachments_id_seq'::regclass) |
|
||||||
|
| post_id | bigint | NO | |
|
||||||
|
| file_path | text | NO | |
|
||||||
|
| file_type | text | YES | 'image'::text |
|
||||||
|
| order_number | integer | NO | 0 |
|
||||||
|
| created_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## feed_posts
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('feed_posts_id_seq'::regclass) |
|
||||||
|
| section | text | NO | |
|
||||||
|
| source_language | text | NO | 'ru'::text |
|
||||||
|
| title_pl | text | YES | |
|
||||||
|
| title_ru | text | YES | |
|
||||||
|
| title_uk | text | YES | |
|
||||||
|
| title_en | text | YES | |
|
||||||
|
| body_pl | text | YES | |
|
||||||
|
| body_ru | text | YES | |
|
||||||
|
| body_uk | text | YES | |
|
||||||
|
| body_en | text | YES | |
|
||||||
|
| link_url | text | YES | |
|
||||||
|
| telegram_url | text | YES | |
|
||||||
|
| author_id | bigint | NO | |
|
||||||
|
| is_pinned | boolean | YES | false |
|
||||||
|
| is_published | boolean | YES | true |
|
||||||
|
| created_at | timestamp without time zone | YES | now() |
|
||||||
|
| updated_at | timestamp without time zone | YES | now() |
|
||||||
|
| edited_at | timestamp without time zone | YES | |
|
||||||
|
| expires_at | timestamp without time zone | YES | |
|
||||||
|
|
||||||
|
## learning_lessons
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('learning_lessons_id_seq'::regclass) |
|
||||||
|
| lesson_id | character varying | NO | |
|
||||||
|
| topic_id | character varying | NO | |
|
||||||
|
| order_number | integer | NO | |
|
||||||
|
| skill_tag | character varying | NO | |
|
||||||
|
| title_pl | text | NO | |
|
||||||
|
| title_ru | text | NO | |
|
||||||
|
| title_uk | text | NO | |
|
||||||
|
| title_en | text | NO | |
|
||||||
|
| objective_pl | text | YES | |
|
||||||
|
| objective_ru | text | YES | |
|
||||||
|
| objective_uk | text | YES | |
|
||||||
|
| objective_en | text | YES | |
|
||||||
|
| explanation_pl | text | YES | |
|
||||||
|
| explanation_ru | text | YES | |
|
||||||
|
| explanation_uk | text | YES | |
|
||||||
|
| explanation_en | text | YES | |
|
||||||
|
| is_active | boolean | YES | true |
|
||||||
|
| edited_at | timestamp without time zone | YES | |
|
||||||
|
|
||||||
|
## learning_levels
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('learning_levels_id_seq'::regclass) |
|
||||||
|
| code | character varying | NO | |
|
||||||
|
| name_pl | text | NO | |
|
||||||
|
| name_ru | text | NO | |
|
||||||
|
| name_uk | text | NO | |
|
||||||
|
| name_en | text | NO | |
|
||||||
|
| sort_order | integer | NO | |
|
||||||
|
| is_active | boolean | YES | true |
|
||||||
|
|
||||||
|
## learning_questions
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('learning_questions_id_seq'::regclass) |
|
||||||
|
| question_id | character varying | NO | |
|
||||||
|
| lesson_id | character varying | YES | |
|
||||||
|
| topic_id | character varying | NO | |
|
||||||
|
| context_type | character varying | NO | |
|
||||||
|
| question_type | character varying | NO | |
|
||||||
|
| skill_tag | character varying | NO | |
|
||||||
|
| difficulty | integer | NO | |
|
||||||
|
| prompt_pl | text | YES | |
|
||||||
|
| prompt_ru | text | YES | |
|
||||||
|
| prompt_uk | text | YES | |
|
||||||
|
| prompt_en | text | YES | |
|
||||||
|
| correct_answer | text | YES | |
|
||||||
|
| hint_type | character varying | YES | |
|
||||||
|
| hint_value | text | YES | |
|
||||||
|
| is_test_question | boolean | YES | false |
|
||||||
|
| test_order | integer | YES | |
|
||||||
|
| options_language | text | YES | 'pl'::text |
|
||||||
|
| edited_at | timestamp without time zone | YES | |
|
||||||
|
|
||||||
|
## learning_sessions
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('learning_sessions_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| level_code | character varying | NO | |
|
||||||
|
| topic_id | character varying | NO | |
|
||||||
|
| session_type | character varying | NO | |
|
||||||
|
| started_at | timestamp without time zone | NO | now() |
|
||||||
|
| completed_at | timestamp without time zone | YES | |
|
||||||
|
| is_completed | boolean | YES | false |
|
||||||
|
|
||||||
|
## learning_topics
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('learning_topics_id_seq'::regclass) |
|
||||||
|
| topic_id | character varying | NO | |
|
||||||
|
| level_code | character varying | NO | |
|
||||||
|
| order_number | integer | NO | |
|
||||||
|
| name_pl | text | NO | |
|
||||||
|
| name_ru | text | NO | |
|
||||||
|
| name_uk | text | NO | |
|
||||||
|
| name_en | text | NO | |
|
||||||
|
| description_pl | text | YES | |
|
||||||
|
| description_ru | text | YES | |
|
||||||
|
| description_uk | text | YES | |
|
||||||
|
| description_en | text | YES | |
|
||||||
|
| is_active | boolean | YES | true |
|
||||||
|
| edited_at | timestamp without time zone | YES | |
|
||||||
|
|
||||||
|
## lesson_examples
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('lesson_examples_id_seq'::regclass) |
|
||||||
|
| lesson_id | character varying | NO | |
|
||||||
|
| order_number | integer | NO | |
|
||||||
|
| text_pl | text | NO | |
|
||||||
|
| text_ru | text | YES | |
|
||||||
|
| text_uk | text | YES | |
|
||||||
|
| text_en | text | YES | |
|
||||||
|
| audio_url | text | YES | |
|
||||||
|
| edited_at | timestamp without time zone | YES | |
|
||||||
|
|
||||||
|
## lesson_progress
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('lesson_progress_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | YES | |
|
||||||
|
| level | text | YES | 'A1'::text |
|
||||||
|
| topic | text | YES | ''::text |
|
||||||
|
| correct_count | integer | YES | 0 |
|
||||||
|
| total_questions | integer | YES | 0 |
|
||||||
|
| created_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## level_words
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('level_words_id_seq'::regclass) |
|
||||||
|
| level_id | integer | YES | |
|
||||||
|
| word_pl | text | NO | |
|
||||||
|
| translation_ru | text | YES | ''::text |
|
||||||
|
| translation_uk | text | YES | ''::text |
|
||||||
|
| translation_en | text | YES | ''::text |
|
||||||
|
| level | text | YES | 'A1'::text |
|
||||||
|
| edited_at | timestamp without time zone | YES | |
|
||||||
|
|
||||||
|
## levels
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('levels_id_seq'::regclass) |
|
||||||
|
| level_number | integer | NO | |
|
||||||
|
| grid_size | integer | NO | |
|
||||||
|
| game_type | text | YES | 'wordsearch'::text |
|
||||||
|
| theme | text | YES | ''::text |
|
||||||
|
| grid_letters | jsonb | NO | '[]'::jsonb |
|
||||||
|
| word_paths | jsonb | NO | '{}'::jsonb |
|
||||||
|
| level | text | YES | 'A1'::text |
|
||||||
|
|
||||||
|
## question_options
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('question_options_id_seq'::regclass) |
|
||||||
|
| question_id | character varying | NO | |
|
||||||
|
| option_key | character varying | NO | |
|
||||||
|
| text_pl | text | YES | |
|
||||||
|
| text_ru | text | YES | |
|
||||||
|
| text_uk | text | YES | |
|
||||||
|
| text_en | text | YES | |
|
||||||
|
| is_correct | boolean | NO | |
|
||||||
|
| wrong_because | character varying | YES | |
|
||||||
|
| edited_at | timestamp without time zone | YES | |
|
||||||
|
|
||||||
|
## sentence_hints_used
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| sentence_id | integer | NO | |
|
||||||
|
| used_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## sentence_progress
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| sentence_id | integer | NO | |
|
||||||
|
| completed_at | timestamp without time zone | YES | |
|
||||||
|
| score | integer | YES | 0 |
|
||||||
|
| level | text | YES | 'A1'::text |
|
||||||
|
|
||||||
|
## sentences
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('sentences_id_seq'::regclass) |
|
||||||
|
| sentence_number | integer | NO | |
|
||||||
|
| theme | text | YES | ''::text |
|
||||||
|
| sentence_pl | text | NO | |
|
||||||
|
| translation_ru | text | YES | ''::text |
|
||||||
|
| translation_uk | text | YES | ''::text |
|
||||||
|
| translation_en | text | YES | ''::text |
|
||||||
|
| difficulty | integer | YES | 1 |
|
||||||
|
| level | text | YES | 'A1'::text |
|
||||||
|
| edited_at | timestamp without time zone | YES | |
|
||||||
|
|
||||||
|
## support_messages
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('support_messages_id_seq'::regclass) |
|
||||||
|
| ticket_id | bigint | NO | |
|
||||||
|
| sender_id | bigint | NO | |
|
||||||
|
| message | text | NO | |
|
||||||
|
| is_read | boolean | YES | false |
|
||||||
|
| created_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## support_tickets
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('support_tickets_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| status | text | YES | 'open'::text |
|
||||||
|
| created_at | timestamp without time zone | YES | now() |
|
||||||
|
| updated_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## teacher_ai_usage
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('teacher_ai_usage_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| usage_date | date | YES | CURRENT_DATE |
|
||||||
|
| command_count | integer | YES | 0 |
|
||||||
|
|
||||||
|
## teacher_chat_history
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('teacher_chat_history_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| messages | jsonb | NO | '[]'::jsonb |
|
||||||
|
| updated_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## teacher_reactions
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('teacher_reactions_id_seq'::regclass) |
|
||||||
|
| reaction_type | character varying | NO | |
|
||||||
|
| text_pl | text | NO | |
|
||||||
|
| text_ru | text | NO | |
|
||||||
|
| text_uk | text | NO | |
|
||||||
|
| text_en | text | NO | |
|
||||||
|
|
||||||
|
## typing_hints_used
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| sentence_id | integer | NO | |
|
||||||
|
| used_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## typing_progress
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| sentence_id | integer | NO | |
|
||||||
|
| completed_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## user_achievements
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| achievement_id | integer | NO | |
|
||||||
|
| unlocked_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## user_learning_answers
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('user_learning_answers_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| session_id | bigint | NO | |
|
||||||
|
| level_code | character varying | NO | |
|
||||||
|
| topic_id | character varying | NO | |
|
||||||
|
| lesson_id | character varying | YES | |
|
||||||
|
| question_id | character varying | NO | |
|
||||||
|
| selected_answer | text | YES | |
|
||||||
|
| correct | boolean | YES | |
|
||||||
|
| skill_tag | character varying | NO | |
|
||||||
|
| question_type | character varying | NO | |
|
||||||
|
| context_type | character varying | NO | |
|
||||||
|
| difficulty | integer | NO | |
|
||||||
|
| time_taken_ms | integer | YES | |
|
||||||
|
| attempt_number | integer | YES | 1 |
|
||||||
|
| hint_used | boolean | YES | false |
|
||||||
|
| wrong_because | character varying | YES | |
|
||||||
|
| is_final_answer | boolean | YES | true |
|
||||||
|
| created_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## user_learning_answers_archive
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('user_learning_answers_archive_id_seq'::re |
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| skill_tag | character varying | NO | |
|
||||||
|
| correct | boolean | YES | |
|
||||||
|
| wrong_because | character varying | YES | |
|
||||||
|
| created_at | date | YES | |
|
||||||
|
| archived_at | timestamp without time zone | YES | now() |
|
||||||
|
|
||||||
|
## user_lesson_progress
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('user_lesson_progress_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| lesson_id | character varying | NO | |
|
||||||
|
| started_at | timestamp without time zone | YES | |
|
||||||
|
| completed_at | timestamp without time zone | YES | |
|
||||||
|
| attempts_count | integer | YES | 0 |
|
||||||
|
| correct_count | integer | YES | 0 |
|
||||||
|
| best_score | numeric | YES | |
|
||||||
|
| average_time_ms | integer | YES | |
|
||||||
|
| completed | boolean | YES | false |
|
||||||
|
|
||||||
|
## user_progress
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| level_id | integer | NO | |
|
||||||
|
| completed_at | timestamp without time zone | YES | |
|
||||||
|
| hints_used | integer | YES | 0 |
|
||||||
|
| score | integer | YES | 0 |
|
||||||
|
| level | text | YES | 'A1'::text |
|
||||||
|
| current_streak | integer | YES | 0 |
|
||||||
|
|
||||||
|
## user_skill_mastery
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('user_skill_mastery_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| skill_tag | character varying | NO | |
|
||||||
|
| attempts_count | integer | YES | 0 |
|
||||||
|
| correct_count | integer | YES | 0 |
|
||||||
|
| recognition_score | numeric | YES | |
|
||||||
|
| production_score | numeric | YES | |
|
||||||
|
| application_score | numeric | YES | |
|
||||||
|
| retention_score | numeric | YES | |
|
||||||
|
| hint_dependency | numeric | YES | |
|
||||||
|
| average_time_ms | integer | YES | |
|
||||||
|
| recent_accuracy | numeric | YES | |
|
||||||
|
| long_term_accuracy | numeric | YES | |
|
||||||
|
| mastery_score | numeric | YES | |
|
||||||
|
| confidence | numeric | YES | |
|
||||||
|
| last_attempt_at | timestamp without time zone | YES | |
|
||||||
|
| median_time_ms | integer | YES | 0 |
|
||||||
|
| recognition_attempts | integer | YES | 0 |
|
||||||
|
| recognition_correct | integer | YES | 0 |
|
||||||
|
| production_attempts | integer | YES | 0 |
|
||||||
|
| production_correct | integer | YES | 0 |
|
||||||
|
| application_attempts | integer | YES | 0 |
|
||||||
|
| application_correct | integer | YES | 0 |
|
||||||
|
| median_correct_time_ms | integer | YES | 0 |
|
||||||
|
| median_wrong_time_ms | integer | YES | 0 |
|
||||||
|
| last_3_accuracy | numeric | YES | |
|
||||||
|
| last_5_accuracy | numeric | YES | |
|
||||||
|
| last_10_accuracy | numeric | YES | |
|
||||||
|
| error_count | integer | YES | 0 |
|
||||||
|
| repeated_error_count | integer | YES | 0 |
|
||||||
|
| days_since_last_attempt | integer | YES | 0 |
|
||||||
|
| previous_mastery_score | numeric | YES | 0 |
|
||||||
|
| mastery_delta | numeric | YES | 0 |
|
||||||
|
| trend | text | YES | 'insufficient_data'::text |
|
||||||
|
| retention_status | text | YES | 'fresh'::text |
|
||||||
|
| fluency_score | numeric | YES | 0 |
|
||||||
|
| passive_knowledge_score | numeric | YES | 0 |
|
||||||
|
| active_knowledge_score | numeric | YES | 0 |
|
||||||
|
|
||||||
|
## user_topic_progress
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | bigint | NO | nextval('user_topic_progress_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| topic_id | character varying | NO | |
|
||||||
|
| lessons_total | integer | YES | 0 |
|
||||||
|
| lessons_completed | integer | YES | 0 |
|
||||||
|
| test_started | boolean | YES | false |
|
||||||
|
| test_completed | boolean | YES | false |
|
||||||
|
| test_score | numeric | YES | |
|
||||||
|
| topic_mastery | numeric | YES | |
|
||||||
|
| confidence | numeric | YES | |
|
||||||
|
| completed_at | timestamp without time zone | YES | |
|
||||||
|
|
||||||
|
## users
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| telegram_id | bigint | NO | |
|
||||||
|
| username | text | YES | |
|
||||||
|
| app_language | text | YES | 'pl'::text |
|
||||||
|
| created_at | timestamp without time zone | YES | now() |
|
||||||
|
| last_completed_level | integer | YES | 0 |
|
||||||
|
| id | integer | NO | nextval('users_id_seq'::regclass) |
|
||||||
|
| current_level | text | YES | 'A1'::text |
|
||||||
|
|
||||||
|
## voice_usage
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('voice_usage_id_seq'::regclass) |
|
||||||
|
| user_id | bigint | YES | |
|
||||||
|
| usage_date | date | YES | CURRENT_DATE |
|
||||||
|
| voice_count | integer | YES | 0 |
|
||||||
|
|
||||||
|
## word_quiz_progress
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| user_id | bigint | NO | |
|
||||||
|
| words_guessed | integer | YES | 0 |
|
||||||
|
| total_score | integer | YES | 0 |
|
||||||
|
| correct_streak | integer | YES | 0 |
|
||||||
|
| recent_words | ARRAY | YES | '{}'::text[] |
|
||||||
|
| level | text | YES | 'A1'::text |
|
||||||
|
| current_mistakes | integer | YES | 0 |
|
||||||
|
|
||||||
|
## wrong_because_explanations
|
||||||
|
|
||||||
|
| Колонка | Тип | NULL | Default |
|
||||||
|
|---------|-----|------|---------|
|
||||||
|
| id | integer | NO | nextval('wrong_because_explanations_id_seq'::regcl |
|
||||||
|
| wrong_because | character varying | NO | |
|
||||||
|
| explanation_pl | text | NO | |
|
||||||
|
| explanation_ru | text | NO | |
|
||||||
|
| explanation_uk | text | NO | |
|
||||||
|
| explanation_en | text | NO | |
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
# 🛣 Все эндпоинты проекта
|
||||||
|
|
||||||
|
## achievements.py
|
||||||
|
**Префикс:** `/achievements`
|
||||||
|
|
||||||
|
- `GET /achievements/user`
|
||||||
|
- `POST /achievements/track-login`
|
||||||
|
- `POST /achievements/track-teacher-menu`
|
||||||
|
- `POST /achievements/track-progress`
|
||||||
|
- `POST /achievements/track-cheatsheets`
|
||||||
|
- `POST /achievements/track-pronunciation`
|
||||||
|
- `POST /achievements/track-ai-assistant`
|
||||||
|
- `POST /achievements/track-alphabet`
|
||||||
|
- `POST /achievements/track-rules`
|
||||||
|
|
||||||
|
## admin.py
|
||||||
|
**Префикс:** `/admin`
|
||||||
|
|
||||||
|
- `GET /admin/dashboard`
|
||||||
|
- `GET /admin/sentry-errors`
|
||||||
|
|
||||||
|
## admin_content.py
|
||||||
|
**Префикс:** `/admin/content`
|
||||||
|
|
||||||
|
- `GET /admin/content/summary`
|
||||||
|
- `GET /admin/content/words/levels`
|
||||||
|
- `GET /admin/content/words/level/{level}`
|
||||||
|
- `GET /admin/content/words/word/{word_id}`
|
||||||
|
- `PUT /admin/content/words/word/{word_id}`
|
||||||
|
- `POST /admin/content/words/level/{level}`
|
||||||
|
- `GET /admin/content/texts/levels`
|
||||||
|
- `GET /admin/content/texts/level/{level}`
|
||||||
|
- `GET /admin/content/texts/text/{text_id}`
|
||||||
|
- `PUT /admin/content/texts/text/{text_id}`
|
||||||
|
- `POST /admin/content/texts/level/{level}`
|
||||||
|
- `GET /admin/content/lessons/levels`
|
||||||
|
- `GET /admin/content/lessons/level/{level}/topics`
|
||||||
|
- `GET /admin/content/lessons/topic/{topic_id}`
|
||||||
|
- `GET /admin/content/lessons/lesson/{lesson_id}`
|
||||||
|
- `PUT /admin/content/lessons/lesson/{lesson_id}`
|
||||||
|
- `GET /admin/content/wrong-because`
|
||||||
|
|
||||||
|
## assistant.py
|
||||||
|
**Префикс:** `/assistant`
|
||||||
|
|
||||||
|
- `POST /assistant/chat`
|
||||||
|
- `POST /assistant/save-analytics`
|
||||||
|
- `GET /assistant/stats/personal`
|
||||||
|
- `GET /assistant/stats/admin`
|
||||||
|
- `GET /assistant/limit`
|
||||||
|
- `GET /assistant/history`
|
||||||
|
- `POST /assistant/history/clear`
|
||||||
|
|
||||||
|
## bubblewords.py
|
||||||
|
**Префикс:** `/bubblewords`
|
||||||
|
|
||||||
|
- `GET /bubblewords/next`
|
||||||
|
- `POST /bubblewords/complete`
|
||||||
|
- `GET /bubblewords/progress`
|
||||||
|
|
||||||
|
## feed.py
|
||||||
|
**Префикс:** ``
|
||||||
|
|
||||||
|
- `GET /feed/{section}`
|
||||||
|
- `GET /feed/post/{post_id}`
|
||||||
|
- `POST /admin/feed/post`
|
||||||
|
- `PUT /admin/feed/post/{post_id}`
|
||||||
|
- `POST /admin/feed/post/{post_id}/delete`
|
||||||
|
- `POST /admin/feed/upload-image`
|
||||||
|
- `POST /admin/feed/translate`
|
||||||
|
|
||||||
|
## game.py
|
||||||
|
**Префикс:** `/game`
|
||||||
|
|
||||||
|
- `GET /game/progress`
|
||||||
|
- `GET /game/level/{level_number}`
|
||||||
|
- `POST /game/check-word`
|
||||||
|
- `POST /game/complete-level`
|
||||||
|
|
||||||
|
## hints.py
|
||||||
|
**Префикс:** `/hints`
|
||||||
|
|
||||||
|
- `GET /hints/first-letter/{level_id}`
|
||||||
|
- `GET /hints/word-list/{level_id}`
|
||||||
|
- `GET /hints/remaining/{level_id}`
|
||||||
|
|
||||||
|
## leaderboard.py
|
||||||
|
**Префикс:** `/leaderboard`
|
||||||
|
|
||||||
|
- `GET /leaderboard/admin/stats`
|
||||||
|
- `GET /leaderboard/top`
|
||||||
|
|
||||||
|
## learning.py
|
||||||
|
**Префикс:** `/learning`
|
||||||
|
|
||||||
|
- `GET /learning/levels`
|
||||||
|
- `GET /learning/topics`
|
||||||
|
- `GET /learning/topics/{topic_id}`
|
||||||
|
- `GET /learning/lessons/{lesson_id}`
|
||||||
|
- `GET /learning/test/{topic_id}`
|
||||||
|
- `POST /learning/session/start`
|
||||||
|
- `POST /learning/answer`
|
||||||
|
- `POST /learning/session/complete`
|
||||||
|
- `GET /learning/progress`
|
||||||
|
- `POST /learning/analytics`
|
||||||
|
- `GET /learning/ai/context`
|
||||||
|
- `POST /learning/practice/start`
|
||||||
|
|
||||||
|
## pronunciation.py
|
||||||
|
**Префикс:** `/pronunciation`
|
||||||
|
|
||||||
|
- `GET /pronunciation/next`
|
||||||
|
|
||||||
|
## sentences.py
|
||||||
|
**Префикс:** `/sentences`
|
||||||
|
|
||||||
|
- `GET /sentences/{sentence_id}/hint`
|
||||||
|
- `GET /sentences/next`
|
||||||
|
- `POST /sentences/check`
|
||||||
|
- `GET /sentences/stats`
|
||||||
|
|
||||||
|
## support.py
|
||||||
|
**Префикс:** `/support`
|
||||||
|
|
||||||
|
- `POST /support/send`
|
||||||
|
- `GET /support/user-tickets`
|
||||||
|
- `GET /support/user-messages/{ticket_id}`
|
||||||
|
- `GET /support/user-unread-count`
|
||||||
|
- `POST /support/delete-ticket/{ticket_id}`
|
||||||
|
- `GET /support/admin-tickets`
|
||||||
|
- `GET /support/admin-messages/{ticket_id}`
|
||||||
|
- `POST /support/admin-reply`
|
||||||
|
- `GET /support/unread-count`
|
||||||
|
- `POST /support/translate`
|
||||||
|
|
||||||
|
## teacher.py
|
||||||
|
**Префикс:** `/teacher`
|
||||||
|
|
||||||
|
- `GET /teacher/phrase-of-day`
|
||||||
|
- `POST /teacher/resume`
|
||||||
|
- `POST /teacher/start`
|
||||||
|
- `POST /teacher/answer`
|
||||||
|
- `POST /teacher/explain`
|
||||||
|
- `POST /teacher/examples`
|
||||||
|
- `POST /teacher/free-message`
|
||||||
|
- `POST /teacher/diagnostic-test`
|
||||||
|
- `POST /teacher/translate-to-polish`
|
||||||
|
- `GET /teacher/progress`
|
||||||
|
- `POST /teacher/history/save`
|
||||||
|
- `GET /teacher/history/load`
|
||||||
|
- `POST /teacher/history/clear`
|
||||||
|
|
||||||
|
## typing.py
|
||||||
|
**Префикс:** `/typing`
|
||||||
|
|
||||||
|
- `GET /typing/next`
|
||||||
|
- `POST /typing/check`
|
||||||
|
- `GET /typing/hint/{sentence_id}`
|
||||||
|
- `GET /typing/progress`
|
||||||
|
|
||||||
|
## users.py
|
||||||
|
**Префикс:** `/users`
|
||||||
|
|
||||||
|
- `POST /users/register`
|
||||||
|
- `GET /users/me/is-admin`
|
||||||
|
- `POST /users/set-language`
|
||||||
|
- `POST /users/set-level`
|
||||||
|
|
||||||
|
## wordquiz.py
|
||||||
|
**Префикс:** `/wordquiz`
|
||||||
|
|
||||||
|
- `GET /wordquiz/next`
|
||||||
|
- `POST /wordquiz/check`
|
||||||
|
- `GET /wordquiz/progress`
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Инвентаризация проекта: все эндпоинты + схема базы.
|
||||||
|
|
||||||
|
Запуск: python scripts/dump_inventory.py
|
||||||
|
Результат: endpoints_inventory.md + database_schema.md
|
||||||
|
"""
|
||||||
|
import asyncio
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||||
|
|
||||||
|
from database import get_pool
|
||||||
|
|
||||||
|
|
||||||
|
def dump_endpoints() -> None:
|
||||||
|
"""Собирает все эндпоинты из routers/*.py."""
|
||||||
|
routers_dir = Path("routers")
|
||||||
|
lines = ["# 🛣 Все эндпоинты проекта", ""]
|
||||||
|
total = 0
|
||||||
|
|
||||||
|
for router_file in sorted(routers_dir.glob("*.py")):
|
||||||
|
if router_file.name == "__init__.py":
|
||||||
|
continue
|
||||||
|
|
||||||
|
content = router_file.read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
prefix_match = re.search(r'APIRouter\(prefix="([^"]+)"', content)
|
||||||
|
prefix = prefix_match.group(1) if prefix_match else ""
|
||||||
|
|
||||||
|
endpoints = re.findall(
|
||||||
|
r'@router\.(get|post|put|delete|patch)\("([^"]+)"',
|
||||||
|
content,
|
||||||
|
)
|
||||||
|
|
||||||
|
if endpoints:
|
||||||
|
lines.append(f"## {router_file.name}")
|
||||||
|
lines.append(f"**Префикс:** `{prefix}`")
|
||||||
|
lines.append("")
|
||||||
|
for method, path in endpoints:
|
||||||
|
full_path = f"{prefix}{path}" if path.startswith("/") else f"{prefix}/{path}"
|
||||||
|
lines.append(f"- `{method.upper()} {full_path}`")
|
||||||
|
total += 1
|
||||||
|
lines.append("")
|
||||||
|
|
||||||
|
Path("endpoints_inventory.md").write_text("\n".join(lines), encoding="utf-8")
|
||||||
|
print(f"✅ endpoints_inventory.md — {total} эндпоинтов")
|
||||||
|
|
||||||
|
|
||||||
|
async def dump_schema() -> None:
|
||||||
|
"""Собирает все таблицы и колонки из базы."""
|
||||||
|
pool = await get_pool()
|
||||||
|
async with pool.acquire() as conn:
|
||||||
|
tables = await conn.fetch("""
|
||||||
|
SELECT table_name
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema = 'public'
|
||||||
|
AND table_type = 'BASE TABLE'
|
||||||
|
ORDER BY table_name
|
||||||
|
""")
|
||||||
|
|
||||||
|
lines = ["# 🗄 Схема базы данных", ""]
|
||||||
|
total = 0
|
||||||
|
|
||||||
|
for t in tables:
|
||||||
|
table_name = t["table_name"]
|
||||||
|
lines.append(f"## {table_name}")
|
||||||
|
lines.append("")
|
||||||
|
|
||||||
|
cols = await conn.fetch("""
|
||||||
|
SELECT column_name, data_type, is_nullable, column_default
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = $1
|
||||||
|
ORDER BY ordinal_position
|
||||||
|
""", table_name)
|
||||||
|
|
||||||
|
lines.append("| Колонка | Тип | NULL | Default |")
|
||||||
|
lines.append("|---------|-----|------|---------|")
|
||||||
|
for c in cols:
|
||||||
|
nullable = "YES" if c["is_nullable"] == "YES" else "NO"
|
||||||
|
default = (c["column_default"] or "")[:50]
|
||||||
|
lines.append(f"| {c['column_name']} | {c['data_type']} | {nullable} | {default} |")
|
||||||
|
lines.append("")
|
||||||
|
total += 1
|
||||||
|
|
||||||
|
await pool.close()
|
||||||
|
|
||||||
|
Path("database_schema.md").write_text("\n".join(lines), encoding="utf-8")
|
||||||
|
print(f"✅ database_schema.md — {total} таблиц")
|
||||||
|
|
||||||
|
|
||||||
|
async def main() -> None:
|
||||||
|
dump_endpoints()
|
||||||
|
await dump_schema()
|
||||||
|
print("🎉 Готово!")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(main())
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# 🧪 Smoke-test отчёт (реальный юзер, реальная БД)
|
||||||
|
|
||||||
|
**Дата:** 2026-09-26 09:13 UTC
|
||||||
|
**Итого:** 10/10 сценариев прошли
|
||||||
|
|
||||||
|
## ✅ Подтверждено рабочим
|
||||||
|
|
||||||
|
- **pronunciation_pool_stress** (pronunciation) — 30/30 запросов успешны, 29 уникальных слов
|
||||||
|
- **hints_db_increment** (hints) — GET вернул 200, hints_used 0 → 1
|
||||||
|
- **game_complete_level_full_flow** (game) — idempotent=True, api_score=90, db_score=90
|
||||||
|
- **wordquiz_correct_answer** (wordquiz) — status=200, correct=True, total_score 0 → 50
|
||||||
|
- **wordquiz_wrong_answer** (wordquiz) — status=200, current_mistakes 0 → 1
|
||||||
|
- **bubblewords_complete_flow** (bubblewords) — status=200, levels 0→1, score 0→100
|
||||||
|
- **sentences_check_wrong** (sentences) — status=200, score 0 → 0 (неверный ответ)
|
||||||
|
- **typing_progress_flow** (typing) — status=200, sentence_id=4625, typing_progress записан=True
|
||||||
|
- **users_set_language** (users) — status=200, app_language pl → ru (ожидали ru)
|
||||||
|
- **achievements_track_login** (achievements) — status=200, daily_logins 0 → 1
|
||||||
Reference in New Issue
Block a user