aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-03-25 14:03:17 +0100
committerDaniel Schadt <kingdread@gmx.de>2023-03-25 14:03:17 +0100
commit2d5376d2003364f1a810ac4c7c9fcb38779417da (patch)
treef1265f1dd3c55d9c81e8ec8c20b99dbc23ce670e
parent62fb4209102f6665584c786ef72aa16fa1ffd604 (diff)
downloadfietsboek-2d5376d2003364f1a810ac4c7c9fcb38779417da.tar.gz
fietsboek-2d5376d2003364f1a810ac4c7c9fcb38779417da.tar.bz2
fietsboek-2d5376d2003364f1a810ac4c7c9fcb38779417da.zip
profile: take into account all tracks
With the previous logic, we only counted those that the user themselves uploaded.
-rw-r--r--fietsboek/views/profile.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/fietsboek/views/profile.py b/fietsboek/views/profile.py
index 657f955..6aef499 100644
--- a/fietsboek/views/profile.py
+++ b/fietsboek/views/profile.py
@@ -6,6 +6,8 @@ from pyramid.httpexceptions import HTTPNotFound
from pyramid.request import Request
from pyramid.response import Response
from pyramid.view import view_config
+from sqlalchemy import select
+from sqlalchemy.orm import aliased
from .. import models, util
from ..data import UserDataDir
@@ -40,11 +42,10 @@ def profile(request: Request) -> dict:
max_speed = 0.0
number_of_tracks = 0
+ query = request.context.all_tracks_query()
+ query = select(aliased(models.Track, query)).where(query.c.type == TrackType.ORGANIC)
track: models.Track
- for track in request.context.tracks:
- if track.type != TrackType.ORGANIC:
- continue
-
+ for track in request.dbsession.execute(query).scalars():
meta = TrackWithMetadata(track, request.data_manager)
total_length += meta.length