From 2d5376d2003364f1a810ac4c7c9fcb38779417da Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 25 Mar 2023 14:03:17 +0100 Subject: profile: take into account all tracks With the previous logic, we only counted those that the user themselves uploaded. --- fietsboek/views/profile.py | 9 +++++---- 1 file 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 -- cgit v1.2.3