mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
refactor(server): introduce scoped query builders for recurring filters
This commit is contained in:
parent
1b03bacb7b
commit
11af91cadb
3 changed files with 41 additions and 23 deletions
|
|
@ -112,14 +112,10 @@ export class ReportsService {
|
|||
customTimeEnd,
|
||||
});
|
||||
|
||||
const getArtistsWithCountQB = this.listenRepository
|
||||
.createQueryBuilder("l")
|
||||
.andWhere('l."userId" = :userID', { userID: user.id })
|
||||
.andWhere("l.playedAt BETWEEN :timeStart AND :timeEnd", {
|
||||
timeStart: interval.start,
|
||||
timeEnd: interval.end,
|
||||
})
|
||||
.leftJoin("l.track", "track")
|
||||
const getArtistsWithCountQB = this.listenRepository.scoped
|
||||
.byUser(user)
|
||||
.duringInterval(interval)
|
||||
.leftJoin("listen.track", "track")
|
||||
.leftJoinAndSelect("track.artists", "artists")
|
||||
.groupBy("artists.id")
|
||||
.select("artists.*")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue