Skip to content

Gamification features (draft)#517

Draft
xXPinkmagicXx wants to merge 168 commits intomasterfrom
gamification
Draft

Gamification features (draft)#517
xXPinkmagicXx wants to merge 168 commits intomasterfrom
gamification

Conversation

@xXPinkmagicXx
Copy link
Copy Markdown
Member

@xXPinkmagicXx xXPinkmagicXx commented Apr 2, 2026

Gamification of Zeeguu

In this PR we have added the backend for features such as friends, friend streak, badges, friend leaderboard, classroom leaderboard.

In one image we have added:
image

Database changes

See changes in tools/migration

  • 26-02-19--add_badges.sql
  • 26-02-24-a-add_username.sql
  • 26-02-24-b-add_username.py
  • 26-02-24--friendship_system.sql
  • 26-02-26--add_max_streak_to_user_language.sql
  • 26-02-28--insert_default_badges.sql
  • 26-02-28--add_user_avatar.sql

We have added new tables:

  • friend
  • friend_requests
  • badge
  • badge_level
  • user_badge_level
  • user_badge_progress
  • user_avatar

Testing added

  • test_friends.py (core/model)
  • test_friends.py (api)
  • test_badges.py

Issues and dicussions

Also see sub issues

Breakdown PRs of features

Gamification feature flag

Friends and Profile

Badges

Leaderboards

xXPinkmagicXx and others added 30 commits February 19, 2026 13:27
Previously, the daily streak was updated on ANY authenticated API call
(via the @requires_session decorator), causing streaks to continue even
when users just opened the app without practicing.

Changes:
- Add reset_streak_if_broken() to UserLanguage - resets streak to 0 if
  user hasn't practiced in 2+ days (called on login)
- Change @requires_session to call reset_streak_if_broken() instead of
  update_streak_if_needed() - only resets broken streaks, doesn't increment
- Add update_user_streak() helper function for practice endpoints
- Add streak updates to actual practice endpoints:
  - /report_exercise_outcome (completing exercises)
  - /reading_session_start (starting to read)
  - /listening_session_start (starting to listen)
  - /get_one_translation (translating words while reading)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Saves max_streak and max_streak_date before resetting daily_streak,
so users can see their all-time best even after breaking a streak.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
xXPinkmagicXx and others added 29 commits March 18, 2026 09:54
Merge changes from master to gamification
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Article.find_or_create() was using np_article.html (raw newspaper HTML)
instead of np_article.htmlContent (readability server output). This caused
navigation menus, headers, and footers to appear as bullet-point lists
in shared articles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The LLM returns JSON with literal newlines inside string values
(instead of escaped \n), which json.loads rejects in strict mode.
This caused fallback to DeepSeek (~90s vs ~3s for Anthropic).

Using json.loads(strict=False) accepts these control characters.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Skip expensive tokenization when caller only needs article metadata
(id, language, title). Used by SharedArticleHandler to show the
language choice modal immediately without waiting for NLP processing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Downloads and detects language + title without creating the article
in the DB. Returns instantly for already-existing articles.
Reverts the withContent flag — no longer needed since the share flow
now uses this lightweight endpoint instead of find_or_create_article.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants