Include upper boundary on stats graph zoom

pull/4903/head
Chocobozzz 2022-04-15 10:54:13 +02:00
parent 1222a602a3
commit b3f84d8ddb
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 16 additions and 1 deletions

View File

@ -316,7 +316,7 @@ export class VideoStatsComponent implements OnInit {
const { min, max } = chart.scales.x const { min, max } = chart.scales.x
const startDate = rawData.data[min].date const startDate = rawData.data[min].date
const endDate = rawData.data[max].date const endDate = this.buildZoomEndDate(rawData.groupInterval, rawData.data[max].date)
this.peertubeRouter.silentNavigate([], { startDate, endDate }) this.peertubeRouter.silentNavigate([], { startDate, endDate })
} }
@ -449,4 +449,19 @@ export class VideoStatsComponent implements OnInit {
} }
} }
} }
private buildZoomEndDate (groupInterval: string, last: string) {
const date = new Date(last)
// Remove parts of the date we don't need
if (groupInterval.endsWith(' day') || groupInterval.endsWith(' days')) {
date.setHours(23, 59, 59)
} else if (groupInterval.endsWith(' hour') || groupInterval.endsWith(' hours')) {
date.setMinutes(59, 59)
} else {
date.setSeconds(59)
}
return date.toISOString()
}
} }