Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add missing items to trophy implementation plan

HairyCrabW0d9c02431407
diff --git a/wger/Implement.txt b/wger/Implement.txt
index ef98e2740..434593c2f 100644
--- a/wger/Implement.txt
+++ b/wger/Implement.txt
@@ -71,7 +71,7 @@ PHASE 1: Foundation - Django App & Database Models
- UserStatistics model (denormalized stats for performance):
* user (OneToOneField to User)
- * total_weight_lifted (DecimalField)
+ * total_weight_lifted (DecimalField) - always stored in kg
* total_workouts (PositiveIntegerField)
* current_streak (PositiveIntegerField)
* longest_streak (PositiveIntegerField)
@@ -79,6 +79,9 @@ PHASE 1: Foundation - Django App & Database Models
* earliest_workout_time (TimeField, nullable)
* latest_workout_time (TimeField, nullable)
* weekend_workout_streak (PositiveIntegerField)
+ * last_complete_weekend_date (DateField, nullable) - for tracking consecutive weekends
+ * last_inactive_date (DateField, nullable) - for Phoenix trophy
+ * worked_out_jan_1 (BooleanField) - for New Year trophy
* last_updated (DateTimeField)
1.3 Create and run migrations
@@ -92,6 +95,10 @@ PHASE 1: Foundation - Django App & Database Models
1.5 Add site-wide config option
- Add trophy system toggle to config app or WGER_SETTINGS
+1.6 Register models in Django admin
+ - Create admin.py with ModelAdmin for Trophy, UserTrophy, UserStatistics
+ - Allow admins to manage trophies via Django admin interface
+
PHASE 2: Trophy Checker System
------------------------------
@@ -131,6 +138,8 @@ PHASE 2: Trophy Checker System
2.3 Create checker registry
- Dictionary mapping checker_class strings to actual classes
- Factory function to instantiate checkers
+ - Note: Use simple keys (e.g., 'count_based') rather than full Python paths
+ to avoid breakage if module structure changes
PHASE 3: Statistics Service
@@ -150,6 +159,19 @@ PHASE 3: Statistics Service
- Trigger incremental statistics update
- Trigger trophy evaluation
+3.4 Handle workout deletion and edits
+ - Post-delete signal on WorkoutLog/WorkoutSession
+ - Pre-save signal to detect edits (compare old vs new values)
+ - Recalculate affected statistics on deletion/edit
+
+3.5 Normalize weight units
+ - Convert all weight values to kg before storing in total_weight_lifted
+ - Use user's weight unit preference for conversion
+
+3.6 Handle timezone for time-based trophies
+ - Use user's timezone from profile (if available) or server timezone
+ - Store earliest/latest workout times in user's local time
+
PHASE 4: Trophy Evaluation Engine
---------------------------------
@@ -174,6 +196,11 @@ PHASE 4: Trophy Evaluation Engine
- evaluate_all_users_trophies_task() - periodic batch job
- update_user_statistics_task(user_id) - async stats update
+4.4 Optimize bulk operations
+ - Use select_related/prefetch_related to avoid N+1 queries
+ - Batch database operations where possible
+ - Consider chunking for large user sets
+
PHASE 5: API Endpoints
----------------------
@@ -191,8 +218,18 @@ PHASE 5: API Endpoints
* GET /api/v2/user-trophy/ - list user's earned trophies
* GET /api/v2/user-trophy/progress/ - all trophies with progress
-5.3 Register URLs
+5.3 Create wger/trophies/urls.py
+ - Define URL patterns for trophies app
+ - Include both API and any web views
+
+5.4 Register URLs
- Add routes to wger/urls.py under API v2 router
+ - Include trophies.urls in main urlpatterns
+
+5.5 Define hidden trophy visibility rules
+ - Hidden trophies not earned: exclude from list OR show with placeholder
+ - Hidden trophies earned: show normally with full details
+ - Document the chosen behavior in API response
PHASE 6: Management Commands & Data Loading
@@ -211,6 +248,11 @@ PHASE 6: Management Commands & Data Loading
6.4 Create fixtures
- Initial trophy definitions (the 9 proposed trophies)
+6.5 Add i18n support for trophy content
+ - Consider TrophyTranslation model (similar to ExerciseTranslation)
+ - Or use Django's translation system with fixture translations
+ - Trophy names and descriptions should be translatable
+
PHASE 7: Testing
----------------