Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
7b01e8e
Chaned python version in Dockerfile to version 3.11 to solve issue wi…
xXPinkmagicXx Feb 19, 2026
901bdf6
Working on badge sql and model
xXPinkmagicXx Feb 19, 2026
f66402b
Working on badges
xXPinkmagicXx Feb 24, 2026
fe1c59e
modified the migration script
xXPinkmagicXx Feb 24, 2026
6b7528a
working on badge progress endpoint
xXPinkmagicXx Feb 24, 2026
b350f6e
Working on friendshipsystem
xXPinkmagicXx Feb 24, 2026
6f38346
Started generic implementation for badge level checking
gabortodor Feb 24, 2026
864e4be
Fixed method overload issue with badge levels
klnyzzz33 Feb 25, 2026
dc35879
Added 'update_badge_levels' method and minor schema changes
gabortodor Feb 25, 2026
950d0a7
Added name field to badge level
gabortodor Feb 25, 2026
4c6120b
Merge branch 'gamification' into feature/badges-schema
xXPinkmagicXx Feb 26, 2026
2bcb352
Reverted Python version to 3.12
klnyzzz33 Feb 26, 2026
d4920ec
Merge branch 'gamification' into feature/friendship-system
xXPinkmagicXx Feb 26, 2026
aa51cf6
Working on friends and friend requests
xXPinkmagicXx Feb 26, 2026
fcb8271
Working on the different friends features, sending, cancel friend re…
xXPinkmagicXx Feb 26, 2026
311181c
Deleted cancel friendRequest, because we alreaady have delete_friend_…
xXPinkmagicXx Feb 26, 2026
845c931
friends and friend request features
xXPinkmagicXx Feb 26, 2026
fe4ec58
working on error responses
xXPinkmagicXx Feb 26, 2026
ac6a606
Minor fixes
klnyzzz33 Feb 26, 2026
45f6f2a
updated migration
xXPinkmagicXx Feb 26, 2026
66491f9
Updated friends table the unique constraints
xXPinkmagicXx Feb 26, 2026
1edcd29
fixed database table errors in tests
xXPinkmagicXx Feb 26, 2026
9f8d53d
Fix streak to only update on actual practice activities
mircealungu Feb 26, 2026
315446b
Add max_streak tracking to preserve best streak history
mircealungu Feb 26, 2026
18078a1
Working on migration for adding username
xXPinkmagicXx Feb 26, 2026
d6dcfd5
Added support for several badges
gabortodor Feb 27, 2026
a7c980f
Added support for learned words badge
gabortodor Feb 27, 2026
ce2c3d8
Added support for read articles badge
klnyzzz33 Feb 27, 2026
9b88473
Working on searching for friends and search be username
xXPinkmagicXx Mar 1, 2026
57ff85e
Minor changes
gabortodor Mar 1, 2026
85a8364
Minor changes
gabortodor Mar 2, 2026
8efecdd
Merge remote-tracking branch 'origin/feature/friendship-system' into …
xXPinkmagicXx Mar 3, 2026
1b70357
working on endpoints
xXPinkmagicXx Mar 3, 2026
0b36f73
Aligning endpoints to standards
xXPinkmagicXx Mar 3, 2026
2234f46
Fixing bug, when creating a user. The username has to be set.
xXPinkmagicXx Mar 3, 2026
1d644ce
get pending friend requests
xXPinkmagicXx Mar 3, 2026
fb0c9e8
dont double json
xXPinkmagicXx Mar 3, 2026
3d77552
Minor changes
gabortodor Mar 3, 2026
11f1b6a
search users
xXPinkmagicXx Mar 4, 2026
07ed16c
More usernames to generate
xXPinkmagicXx Mar 4, 2026
505cc53
ilike for case insensitive matching
xXPinkmagicXx Mar 4, 2026
6ca740a
Using the function from user to generate a username instead and updat…
xXPinkmagicXx Mar 4, 2026
c8c138e
user table instead of users
xXPinkmagicXx Mar 4, 2026
6ebdc62
updated the comment in generate username to reflect the correct numbe…
xXPinkmagicXx Mar 4, 2026
2ab6587
Added badge progression tracking
gabortodor Mar 4, 2026
f9e7e52
added back in the "@classmethod" to create_anonymous function in user
xXPinkmagicXx Mar 4, 2026
2e692e4
deleted requests.sh
xXPinkmagicXx Mar 4, 2026
e1e0b20
Fixing indentation in friends.py
xXPinkmagicXx Mar 4, 2026
3331682
clean up indentation in friend.py (in model folder)
xXPinkmagicXx Mar 4, 2026
32ff0ef
fixed indentation for friend_request.py
xXPinkmagicXx Mar 4, 2026
297dcc6
Merge branch 'fix-streak-only-on-practice' into feature/badges-schema
klnyzzz33 Mar 5, 2026
87ced7c
Streak count badge now calculates the highest current value among all…
klnyzzz33 Mar 5, 2026
f6db4c2
Removed badge is_hidden field, updated badge default values
gabortodor Mar 7, 2026
b3ad1da
Add hide_recommendations feature flag for cohort 564
mircealungu Feb 26, 2026
ddda23d
Exclude teachers from hide_recommendations feature
mircealungu Feb 26, 2026
04f37c7
Update .envrc to use local .venv
mircealungu Mar 5, 2026
1231aa6
Update CLAUDE.md venv path
mircealungu Mar 5, 2026
c34b6a5
Merge branch 'gamification' into feature/friendship-system
xXPinkmagicXx Mar 9, 2026
649bdc9
Working on test for the friends endpoints
xXPinkmagicXx Mar 9, 2026
836d0d4
Tests for the friends endpoints
xXPinkmagicXx Mar 10, 2026
3d09894
Removed discover_friends endpoint
xXPinkmagicXx Mar 10, 2026
510454d
Fixed spaces in tests
xXPinkmagicXx Mar 10, 2026
e4759f3
Deleted print statement
xXPinkmagicXx Mar 10, 2026
a8e32bb
Fixed indentation and added logging for friends endpoints
xXPinkmagicXx Mar 10, 2026
5bf0f68
Added line
xXPinkmagicXx Mar 10, 2026
cfd8d6c
adjusted test
xXPinkmagicXx Mar 10, 2026
577d8f1
updated the accept_friend_request method
xXPinkmagicXx Mar 10, 2026
13f8361
Merge branch 'gamification' into feature/badges-schema
gabortodor Mar 11, 2026
08cae1f
Working on friend streak feature
xXPinkmagicXx Mar 11, 2026
5d58ca9
Fixed issue in the migration script
gabortodor Mar 11, 2026
60d65f3
working on testing friends streak
xXPinkmagicXx Mar 11, 2026
fb43aa9
Merge branch 'master' into gamification
xXPinkmagicXx Mar 11, 2026
934cd1a
Merge branch 'gamification' into feature/friendship-system
xXPinkmagicXx Mar 11, 2026
af8a619
Merge branch 'gamification' into feature/badges-schema
xXPinkmagicXx Mar 11, 2026
b1cf262
Merge pull request #494 from zeeguu/feature/friendship-system
xXPinkmagicXx Mar 11, 2026
2a492bf
Refactored badges migration scripts + endpoint prefix
gabortodor Mar 11, 2026
4b708e1
Merge remote-tracking branch 'origin/feature/badges-schema' into feat…
gabortodor Mar 11, 2026
5c0f809
Merge branch 'gamification' into feature/badges-schema
gabortodor Mar 11, 2026
91528ef
Merge pull request #499 from zeeguu/feature/badges-schema
gabortodor Mar 11, 2026
ccba5c8
Merge branch 'gamification' into feature/friend-streak
xXPinkmagicXx Mar 11, 2026
50f1985
Merge branch 'feature/friend-streak' of https://github.com/zeeguu/api…
xXPinkmagicXx Mar 11, 2026
0ecb0a6
Working on the friends streak functinoality
xXPinkmagicXx Mar 11, 2026
b069f55
Update friend streak implemented
xXPinkmagicXx Mar 11, 2026
be08968
Always run the update_friends_streak
xXPinkmagicXx Mar 11, 2026
2603bb5
Added created_at in the return value for get_user_details()
klnyzzz33 Mar 12, 2026
b690d6e
Merge branch 'gamification' into feature/profile
klnyzzz33 Mar 12, 2026
a6389ab
working on get friends and friend_streak
xXPinkmagicXx Mar 12, 2026
a02b75d
Added friend_streak and last_updated to the get_friends endpoint
xXPinkmagicXx Mar 12, 2026
126ef9d
same response for search users and get_friends
xXPinkmagicXx Mar 12, 2026
705f983
Added endpoint for fetching daily streak information for all active l…
klnyzzz33 Mar 12, 2026
85ec2ff
updated the friend_streak_logic
xXPinkmagicXx Mar 12, 2026
5df8962
use local time instead of UTC (for now)
xXPinkmagicXx Mar 12, 2026
3e716bb
Get friend details
xXPinkmagicXx Mar 12, 2026
5d19b45
Added user avatars and returning them on /get_user_details
klnyzzz33 Mar 13, 2026
6833e29
Username now also gets saved on /user_settings
klnyzzz33 Mar 13, 2026
f9d6a5f
Added avatar saving for users
gabortodor Mar 14, 2026
5824671
Merge branch 'master' into gamification
gabortodor Mar 14, 2026
5c1dc98
Merge branch 'gamification' into feature/profile
gabortodor Mar 14, 2026
f0228b0
User avatar saving refactor
klnyzzz33 Mar 14, 2026
d00bf86
Fixed friendship migration script
gabortodor Mar 15, 2026
b484825
Minor badge improvements
gabortodor Mar 15, 2026
1412d02
Update friend streak and db session logic
xXPinkmagicXx Mar 17, 2026
8a9f25b
try to fix broken env in pipeline
xXPinkmagicXx Mar 17, 2026
281add9
fix tests
xXPinkmagicXx Mar 17, 2026
d999f4a
Merge pull request #503 from zeeguu/feature/friend-streak
xXPinkmagicXx Mar 17, 2026
f191830
added friend streak to the migration
xXPinkmagicXx Mar 17, 2026
985913c
added tests for the get_user_details for friends
xXPinkmagicXx Mar 17, 2026
759e356
Added created_at in the return value for get_user_details()
klnyzzz33 Mar 12, 2026
e18d5b6
Added endpoint for fetching daily streak information for all active l…
klnyzzz33 Mar 12, 2026
9ca81a7
Added user avatars and returning them on /get_user_details
klnyzzz33 Mar 13, 2026
7e1b29d
Username now also gets saved on /user_settings
klnyzzz33 Mar 13, 2026
16d1757
Added avatar saving for users
gabortodor Mar 14, 2026
a1b2941
Hide non-simplified articles from recommendations
mircealungu Mar 13, 2026
d445ab9
Allow setting password via /user_settings endpoint
mircealungu Mar 13, 2026
080028f
Add atomic account upgrade to avoid email verification limbo state
mircealungu Mar 13, 2026
6b38b55
Add @allows_unverified to daily_streak endpoint
mircealungu Mar 13, 2026
8cac124
Revert @allows_unverified from daily_streak, user_settings, user_pref…
mircealungu Mar 13, 2026
cd42623
Simplify verification codes to 4-digit numeric
mircealungu Mar 13, 2026
45a112d
Fix starred/liked articles not showing due to recommendation filter
mircealungu Mar 13, 2026
21ae2ff
Add migration to fix exercise_report reason ENUM missing wrong_highli…
mircealungu Mar 13, 2026
d35a8bd
Filter hidden articles from unfinished reading sessions
mircealungu Mar 13, 2026
dd1db86
User avatar saving refactor
klnyzzz33 Mar 14, 2026
590c5a6
Fixed friendship migration script
gabortodor Mar 15, 2026
3e2f61b
Minor badge improvements
gabortodor Mar 15, 2026
e16ce7d
updated the friend_streak_logic
xXPinkmagicXx Mar 12, 2026
c27da60
use local time instead of UTC (for now)
xXPinkmagicXx Mar 12, 2026
1e1b889
Update friend streak and db session logic
xXPinkmagicXx Mar 17, 2026
9179b4b
try to fix broken env in pipeline
xXPinkmagicXx Mar 17, 2026
70735f7
fix tests
xXPinkmagicXx Mar 17, 2026
9fe62cb
Working on get data for see friend user profile
xXPinkmagicXx Mar 17, 2026
93fce8c
Exclude yourslef as as a friend
xXPinkmagicXx Mar 17, 2026
d3b227c
Working on see friend / user profile
xXPinkmagicXx Mar 17, 2026
d071bcb
return friendship info in the get_user_details
xXPinkmagicXx Mar 17, 2026
3d17d29
Added avatar saving for users
gabortodor Mar 14, 2026
307d8cd
Allow setting password via /user_settings endpoint
mircealungu Mar 13, 2026
6bd99fd
Add atomic account upgrade to avoid email verification limbo state
mircealungu Mar 13, 2026
ab089db
Add @allows_unverified to daily_streak endpoint
mircealungu Mar 13, 2026
8526f2f
Revert @allows_unverified from daily_streak, user_settings, user_pref…
mircealungu Mar 13, 2026
dd79075
User avatar saving refactor
klnyzzz33 Mar 14, 2026
854d5cc
Update friend streak and db session logic
xXPinkmagicXx Mar 17, 2026
685a762
fix tests
xXPinkmagicXx Mar 17, 2026
e60323b
Working on friendship and language
xXPinkmagicXx Mar 18, 2026
f4dd1d8
Merge branch 'feature/profile' into feature/see-friend-profile
gabortodor Mar 18, 2026
1deb9ba
Merge pull request #506 from zeeguu/feature/see-friend-profile
gabortodor Mar 18, 2026
8b054cf
the user language info
xXPinkmagicXx Mar 18, 2026
b2b45ca
Merge branch 'master' into gamification
xXPinkmagicXx Mar 19, 2026
12123d4
Modified get_badges_for_user return value
klnyzzz33 Mar 19, 2026
8eb6cdf
Extended get_all_daily_streak for friend profiles as well
klnyzzz33 Mar 19, 2026
cb9f9a4
Merge pull request #507 from zeeguu/feature/profile
klnyzzz33 Mar 20, 2026
156b1f7
Now with gamification feature flag
xXPinkmagicXx Mar 25, 2026
1825806
Working on the gamification feature flag
xXPinkmagicXx Mar 25, 2026
9ee3ff0
Deleted comment
xXPinkmagicXx Mar 25, 2026
7c17948
working on feature flags for all gamification features
xXPinkmagicXx Mar 25, 2026
7544574
Invite code for all features
xXPinkmagicXx Mar 26, 2026
b0b2470
Is dev for the gamification feature
xXPinkmagicXx Mar 26, 2026
3d25288
clean up logic for gamification
xXPinkmagicXx Mar 31, 2026
6b0d49c
Merge pull request #514 from zeeguu/master
klnyzzz33 Mar 31, 2026
094b345
update the gamification flag logic
xXPinkmagicXx Apr 2, 2026
f284eb0
Add upgrade_to_teacher tool script
mircealungu Mar 24, 2026
0e52cdd
Fix article extraction to use readability-cleaned HTML
mircealungu Mar 26, 2026
5634673
Fix Anthropic JSON parsing: accept literal newlines from LLM
mircealungu Mar 27, 2026
fa60ee5
Support withContent=false in find_or_create_article
mircealungu Mar 27, 2026
fd67d58
Add lightweight /detect_article_info endpoint for share modal
mircealungu Mar 27, 2026
ab24d8b
Show non-simplified articles only for legacy users via feature toggle
mircealungu Mar 29, 2026
68effaf
Merge branch 'gamification' into feature/gamification-feature-flag
xXPinkmagicXx Apr 2, 2026
c221051
fix invitation code check
xXPinkmagicXx Apr 2, 2026
871fcab
Try except logic for gamification cohort
xXPinkmagicXx Apr 2, 2026
073d5f1
Merge pull request #509 from zeeguu/feature/gamification-feature-flag
xXPinkmagicXx Apr 2, 2026
3cac4db
Merge branch 'master' into gamification
gabortodor Apr 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ jobs:
source venv/bin/activate
export NLTK_DATA=$ZEEGUU_RESOURCES_FOLDER/nltk_data
export DEV_SKIP_TRANSLATION=1
pytest
python -m pytest
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ COPY ./setup.py /Zeeguu-API/setup.py

WORKDIR /Zeeguu-API

# RUN python -m pip install --upgrade pip setuptools
# Install Python requirements with BuildKit cache mount
# Cache persisted via buildkit-cache-dance action to GitHub Actions cache
RUN --mount=type=cache,target=/root/.cache/pip \
echo "=== Pip cache before install ===" && \
ls -lah /root/.cache/pip 2>/dev/null || echo "Cache empty (first build)" && \
python -m pip install -r requirements.txt && \
python -m pip install gunicorn && \
python -m pip install --default-timeout=300 -r requirements.txt && \
python -m pip install --default-timeout=300 gunicorn && \
echo "=== Pip cache after install ===" && \
du -sh /root/.cache/pip

Expand Down
41 changes: 41 additions & 0 deletions tools/migrations/26-02-19--add_badges.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- tools/migrations/26-02-19--add_badge_and_user_badge_tables.sql

CREATE TABLE badge (
id INT AUTO_INCREMENT PRIMARY KEY,
code VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
description TEXT,
UNIQUE(code)
);

CREATE TABLE badge_level (
id INT AUTO_INCREMENT PRIMARY KEY,
badge_id INT NOT NULL,
name VARCHAR(100),
level INT NOT NULL,
target_value INT NOT NULL,
icon_name VARCHAR(255),
UNIQUE(badge_id, level),
FOREIGN KEY (badge_id) REFERENCES badge(id)
);

CREATE TABLE user_badge_level (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
badge_level_id INT NOT NULL,
achieved_at DATETIME DEFAULT NULL,
is_shown BOOLEAN DEFAULT FALSE,
UNIQUE(user_id, badge_level_id),
FOREIGN KEY (user_id) REFERENCES user(id),
FOREIGN KEY (badge_level_id) REFERENCES badge_level(id)
);

CREATE TABLE user_badge_progress (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
badge_id INT NOT NULL,
current_value INT NOT NULL,
UNIQUE(user_id, badge_id),
FOREIGN KEY (user_id) REFERENCES user(id),
FOREIGN KEY (badge_id) REFERENCES badge(id)
);
21 changes: 21 additions & 0 deletions tools/migrations/26-02-24-a-add_username.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ALTER TABLE user
ADD COLUMN username VARCHAR(50);

-- This is maybe needed
SET SQL_SAFE_UPDATES = 0;

-- Option 1 user_<id>
UPDATE user
SET username = CONCAT('user_', id)
WHERE id IS NOT NULL
AND username IS NULL;

-- In that case remember to enable it again
SET SQL_SAFE_UPDATES = 1;

-- Change the column to be not null and unique
ALTER TABLE user
MODIFY username VARCHAR(50) NOT NULL;

ALTER TABLE user
ADD CONSTRAINT unique_username UNIQUE (username);
46 changes: 46 additions & 0 deletions tools/migrations/26-02-24-b-add_username.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python
"""
Migration script to automatically populate usernames for existing users.

The usernames are generated in the format 'adjective_noun1234' (e.g., 'brave_tiger5678')
and are guaranteed to be unique across the user base.
This script should be run after the database schema has been updated to include the new 'username' column in the 'user' table.

26-02-24-a-add_username.sql should have been run first to add the 'username' column to the 'user' table.

Run with: source ~/.venvs/z_env/bin/activate && python tools/migrations/26-02-24-b-add_username.py
"""
import sys
import os

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

from zeeguu.core.model.user import User
from zeeguu.core.model import db

def generate_unique_username():

while True:
username = User.generate_username()
exists = User.query.filter_by(username=username).first()
if not exists:
return username

def populate_usernames():
users : list[User] = User.query.all()
for user in users:
user.username = generate_unique_username()
db.session.commit()


if __name__ == "__main__":

from zeeguu.api.app import create_app
from zeeguu.core.model import db

app = create_app()
app.app_context().push()

print("Starting random username population...")
populate_usernames()
print("Username population completed.")
25 changes: 25 additions & 0 deletions tools/migrations/26-02-24-friendship_system.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- friends table
CREATE TABLE friends (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
friend_id INT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
friend_streak INT DEFAULT 0,
friend_streak_last_updated DATETIME,
CONSTRAINT unique_user_friend UNIQUE (user_id, friend_id),
CONSTRAINT unique_friend_user UNIQUE (friend_id, user_id),
FOREIGN KEY (user_id) REFERENCES user(id),
FOREIGN KEY (friend_id) REFERENCES user(id)
);

-- Friend requests table
CREATE TABLE friend_requests (
id INT AUTO_INCREMENT PRIMARY KEY,
sender_id INT NOT NULL,
receiver_id INT NOT NULL,
status ENUM('pending', 'accepted', 'rejected') DEFAULT 'pending',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
responded_at DATETIME,
FOREIGN KEY (sender_id) REFERENCES user(id),
FOREIGN KEY (receiver_id) REFERENCES user(id)
);
10 changes: 10 additions & 0 deletions tools/migrations/26-02-26--add_max_streak_to_user_language.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Add max_streak tracking to user_language table
ALTER TABLE user_language
ADD COLUMN max_streak INT NOT NULL DEFAULT 0,
ADD COLUMN max_streak_date DATETIME NULL;

-- Seed max_streak from current daily_streak for users with active streaks
UPDATE user_language
SET max_streak = daily_streak,
max_streak_date = last_practiced
WHERE daily_streak > 0;
62 changes: 62 additions & 0 deletions tools/migrations/26-02-28--insert_default_badges.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
-- tools/migrations/26-02-28--insert_default_badge.sql

INSERT INTO badge (id, code, name, description)
VALUES
(1, 'TRANSLATED_WORDS', 'Meaning Builder', 'Translate {target_value} unique words while reading.'),
(2, 'CORRECT_EXERCISES', 'Practice Builder', 'Solve {target_value} exercises correctly.'),
(3, 'COMPLETED_AUDIO_LESSONS', 'Sound Scholar', 'Complete {target_value} audio lessons.'),
(4, 'STREAK_COUNT', 'Consistency Champion', 'Maintain a streak for {target_value} days.'),
(5, 'LEARNED_WORDS', 'Word Collector', 'Learn {target_value} new words.'),
(6, 'READ_ARTICLES', 'Active Reader', 'Read {target_value} articles.'),
(7, 'NUMBER_OF_FRIENDS', 'Influencer', 'Add {target_value} friends.');

INSERT INTO badge_level (id, badge_id, name, level, target_value, icon_name)
VALUES
-- Translated Words
(1, 1, '', 1, 10, NULL),
(2, 1, '', 2, 100, NULL),
(3, 1, '', 3, 500, NULL),
(4, 1, '', 4, 1000, NULL),
(5, 1, '', 5, 2500, NULL),

-- Correct Exercises
(6, 2, '', 1, 10, NULL),
(7, 2, '', 2, 250, NULL),
(8, 2, '', 3, 1000, NULL),
(9, 2, '', 4, 5000, NULL),
(10, 2, '', 5, 20000, NULL),

-- Completed Audio Lessons
(11, 3, '', 1, 1, NULL),
(12, 3, '', 2, 25, NULL),
(13, 3, '', 3, 50, NULL),
(14, 3, '', 4, 150, NULL),
(15, 3, '', 5, 300, NULL),

-- Streak Count
(16, 4, '', 1, 7, NULL),
(17, 4, '', 2, 30, NULL),
(18, 4, '', 3, 90, NULL),
(19, 4, '', 4, 180, NULL),
(20, 4, '', 5, 365, NULL),

-- Learned Words
(21, 5, '', 1, 1, NULL),
(22, 5, '', 2, 10, NULL),
(23, 5, '', 3, 50, NULL),
(24, 5, '', 4, 250, NULL),
(25, 5, '', 5, 750, NULL),

-- Read Articles
(26, 6, '', 1, 5, NULL),
(27, 6, '', 2, 25, NULL),
(28, 6, '', 3, 100, NULL),
(29, 6, '', 4, 500, NULL),
(30, 6, '', 5, 1000, NULL),

-- Number of Friends
(31, 7, '', 1, 1, NULL),
(32, 7, '', 2, 3, NULL),
(33, 7, '', 3, 5, NULL),
(34, 7, '', 4, 7, NULL),
(35, 7, '', 5, 10, NULL);
9 changes: 9 additions & 0 deletions tools/migrations/26-03-13--add_user_avatar.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE user_avatar (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
image_name VARCHAR(100),
character_color VARCHAR(7),
background_color VARCHAR(7),
UNIQUE(user_id),
FOREIGN KEY (user_id) REFERENCES user(id)
);
2 changes: 2 additions & 0 deletions zeeguu/api/endpoints/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@
from . import user_stats
from . import session_history
from . import daily_streak
from . import badges
from . import friends
14 changes: 9 additions & 5 deletions zeeguu/api/endpoints/activity_tracking.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import flask
from flask import request

from zeeguu.api.utils.route_wrappers import cross_domain, requires_session
from zeeguu.core.badges.badge_progress import increment_badge_progress, BadgeCode
from zeeguu.core.model import UserActivityData, User
from zeeguu.core.user_activity_hooks.article_interaction_hooks import (
distill_article_interactions,
)

from . import api, db_session
from zeeguu.api.utils.route_wrappers import cross_domain, requires_session
from zeeguu.core.model import UserActivityData, User


@api.route("/upload_user_activity_data", methods=["POST"])
Expand Down Expand Up @@ -102,10 +103,10 @@ def _check_and_notify_article_completion_on_scroll(user, form_data):
# Debug: log the scroll data structure
from zeeguu.logging import log
log(f"[article_completion] Scroll data received: {scroll_data[:3] if isinstance(scroll_data, list) and len(scroll_data) > 3 else scroll_data}")

# Use a more lenient approach or fallback to max percentage
completion_percentage = find_last_reading_percentage(scroll_data, max_jump=50, max_total_update=80)

# Fallback: if the algorithm returns 0 but we have scroll data, use max percentage
if completion_percentage == 0 and scroll_data:
max_percentage = max([point[1] for point in scroll_data if len(point) >= 2]) / 100.0
Expand Down Expand Up @@ -135,6 +136,9 @@ def _check_and_notify_article_completion_on_scroll(user, form_data):

user_article.completed_at = datetime.now()

# Update READ_ARTICLES badge progress
increment_badge_progress(db_session, BadgeCode.READ_ARTICLES, user.id)

# Send notification if enabled
from flask import current_app

Expand Down
Loading
Loading