From 471f46eb8d2d8347abca9a6a379559cd4f40efa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Fri, 17 Mar 2023 17:35:54 +0100 Subject: [PATCH] fix(api): album&track reports only contain one artist Albums & Tracks can have multiple artists associated with them, but the previous SQL queries would only return a randomly-chosen one of them. --- src/reports/reports.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/reports/reports.service.ts b/src/reports/reports.service.ts index 6c009d5..2e2e871 100644 --- a/src/reports/reports.service.ts +++ b/src/reports/reports.service.ts @@ -152,7 +152,7 @@ export class ReportsService { .leftJoinAndSelect("listen.track", "track") .leftJoinAndSelect("track.album", "album") .leftJoinAndSelect("album.artists", "artists") - .distinctOn(["album.id"]) + .distinctOn(["album.id", "artists.id"]) .getMany(), ]); @@ -189,7 +189,7 @@ export class ReportsService { this.getListensQueryFromOptions(options) .leftJoinAndSelect("listen.track", "track") .leftJoinAndSelect("track.artists", "artists") - .distinctOn(["track.id"]) + .distinctOn(["track.id", "artists.id"]) .getMany(), ]);