From 6349881dbd3ea514a73341afd9baac4b2eb0baaa Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 23 Nov 2023 09:39:56 +0100 Subject: [PATCH] Fix graph zooming end date --- .../app/+stats/video/video-stats.component.ts | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/client/src/app/+stats/video/video-stats.component.ts b/client/src/app/+stats/video/video-stats.component.ts index 8bd1ac1f2..1fdfb9f5e 100644 --- a/client/src/app/+stats/video/video-stats.component.ts +++ b/client/src/app/+stats/video/video-stats.component.ts @@ -449,7 +449,9 @@ export class VideoStatsComponent implements OnInit { const { min, max } = chart.scales.x const startDate = rawData.data[min].date - const endDate = this.buildZoomEndDate(rawData.groupInterval, rawData.data[max].date) + const endDate = max === rawData.data.length - 1 + ? (this.statsEndDate || new Date()).toISOString() + : rawData.data[max + 1].date this.peertubeRouter.silentNavigate([], { startDate, endDate }) this.addAndSelectCustomDateFilter() @@ -605,19 +607,4 @@ export class VideoStatsComponent implements OnInit { second: 'numeric' }) } - - 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() - } }