diff options
-rw-r--r-- | fietsboek/views/profile.py | 9 |
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 |