Skip to content

Commit

Permalink
fix(modules/reports/service): fix getting most listened hours
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnigos committed Sep 2, 2024
1 parent c35d0ca commit 326f02b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/modules/reports/reports.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ describe('ReportsService', () => {
userMock
)
).toEqual({
0: getCount(0),
1: getCount(1),
2: getCount(2),
3: getCount(3),
Expand All @@ -179,7 +180,6 @@ describe('ReportsService', () => {
21: getCount(21),
22: getCount(22),
23: getCount(23),
24: getCount(24),
})

expect(findByUserAndBetweenDatesSpy).toHaveBeenCalledWith(
Expand Down Expand Up @@ -231,6 +231,7 @@ describe('ReportsService', () => {
userMock
)
).toEqual({
0: getTotalDuration(0),
1: getTotalDuration(1),
2: getTotalDuration(2),
3: getTotalDuration(3),
Expand All @@ -254,7 +255,6 @@ describe('ReportsService', () => {
21: getTotalDuration(21),
22: getTotalDuration(22),
23: getTotalDuration(23),
24: getTotalDuration(24),
})

expect(findByUserAndBetweenDatesSpy).toHaveBeenCalledWith(
Expand Down
4 changes: 2 additions & 2 deletions src/modules/reports/reports.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class ReportsService {

const DAY_HOURS = 24

for (let index = 1; index <= DAY_HOURS; index++) {
for (let index = 0; index < DAY_HOURS; index++) {
const historyTracksWithinSearchedHour = historyTracks.filter(
({ playedAt }) => playedAt.getHours() === index
)
Expand All @@ -105,7 +105,7 @@ export class ReportsService {
return listeningHoursObject
}

async getTotalTracks(
getTotalTracks(
{ before, after }: Required<ReportsTotalItemsQuery>,
user: User
) {
Expand Down

0 comments on commit 326f02b

Please sign in to comment.