Skip to content

Commit

Permalink
Wrong difficulty for multipitch routes in statistics
Browse files Browse the repository at this point in the history
Fixes #164
  • Loading branch information
zoranmesec committed Sep 18, 2023
1 parent 8054c27 commit 40c115a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/activities/services/activity-routes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ export class ActivityRoutesService {
const builder = this.activityRoutesRepository
.createQueryBuilder('ar')
.select('EXTRACT(YEAR FROM ar.date)', 'year')
.addSelect('r.difficulty', 'difficulty')
.addSelect('coalesce(p.difficulty, r.difficulty)', 'difficulty')
.addSelect('ar.ascent_type', 'ascent_type')
.addSelect('count(ar.id)', 'nr_ascents')
.addSelect('count(r.id)', 'nr_routes')
Expand All @@ -532,8 +532,8 @@ export class ActivityRoutesService {
"(r.publish_status IN ('published', 'in_review') OR (r.publish_status = 'draft' AND ar.user_id = :userId))",
{ userId: currentUser.id },
)
.groupBy("r.difficulty").addGroupBy("EXTRACT(YEAR FROM ar.date)").addGroupBy("ar.ascent_type")
.orderBy('r.difficulty', 'ASC')
.groupBy("p.difficulty").addGroupBy(("r.difficulty")).addGroupBy("EXTRACT(YEAR FROM ar.date)").addGroupBy("ar.ascent_type")
.orderBy('coalesce(p.difficulty, r.difficulty)', 'ASC')
.addOrderBy('year', 'ASC');

setBuilderCache(builder, 'getRawAndEntities');
Expand Down

0 comments on commit 40c115a

Please sign in to comment.