From 74c64aa63070a6985b3553aaeb25e29cdd068946 Mon Sep 17 00:00:00 2001 From: oldnapalm <38410858+oldnapalm@users.noreply.github.com> Date: Fri, 16 Feb 2024 17:18:41 -0300 Subject: [PATCH] Update ZCA route badges --- zwift_offline.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zwift_offline.py b/zwift_offline.py index 96d5caf4..d4389179 100644 --- a/zwift_offline.py +++ b/zwift_offline.py @@ -3291,10 +3291,11 @@ def api_route_results_completion_stats_all(): for achievement in achievements.achievements: if achievement.id in GD['achievements']: badges.append(GD['achievements'][achievement.id]) - if db.session.execute(sqlalchemy.text("SELECT COUNT(*) FROM route_result WHERE player_id = :p"), {"p": player_id}).scalar() < len(badges): - for badge in badges: + results = [r[0] for r in db.session.execute(sqlalchemy.text("SELECT route_hash FROM route_result WHERE player_id = :p"), {"p": player_id})] + for badge in badges: + if not badge in results: db.session.add(RouteResult(player_id=player_id, route_hash=badge)) - db.session.commit() + db.session.commit() stats = [] rows = db.session.execute(sqlalchemy.text("SELECT route_hash, min(world_time) AS first, max(world_time) AS last FROM route_result WHERE player_id = :p GROUP BY route_hash"), {"p": player_id}) for row in rows: