aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+stats/video/video-stats.component.ts17
-rw-r--r--client/src/assets/player/shared/peertube/peertube-plugin.ts4
2 files changed, 18 insertions, 3 deletions
diff --git a/client/src/app/+stats/video/video-stats.component.ts b/client/src/app/+stats/video/video-stats.component.ts
index 14db31ecf..8200661c3 100644
--- a/client/src/app/+stats/video/video-stats.component.ts
+++ b/client/src/app/+stats/video/video-stats.component.ts
@@ -316,7 +316,7 @@ export class VideoStatsComponent implements OnInit {
316 const { min, max } = chart.scales.x 316 const { min, max } = chart.scales.x
317 317
318 const startDate = rawData.data[min].date 318 const startDate = rawData.data[min].date
319 const endDate = rawData.data[max].date 319 const endDate = this.buildZoomEndDate(rawData.groupInterval, rawData.data[max].date)
320 320
321 this.peertubeRouter.silentNavigate([], { startDate, endDate }) 321 this.peertubeRouter.silentNavigate([], { startDate, endDate })
322 } 322 }
@@ -449,4 +449,19 @@ export class VideoStatsComponent implements OnInit {
449 } 449 }
450 } 450 }
451 } 451 }
452
453 private buildZoomEndDate (groupInterval: string, last: string) {
454 const date = new Date(last)
455
456 // Remove parts of the date we don't need
457 if (groupInterval.endsWith(' day') || groupInterval.endsWith(' days')) {
458 date.setHours(23, 59, 59)
459 } else if (groupInterval.endsWith(' hour') || groupInterval.endsWith(' hours')) {
460 date.setMinutes(59, 59)
461 } else {
462 date.setSeconds(59)
463 }
464
465 return date.toISOString()
466 }
452} 467}
diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts
index 8b65903f9..a29a0921f 100644
--- a/client/src/assets/player/shared/peertube/peertube-plugin.ts
+++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts
@@ -159,7 +159,7 @@ class PeerTubePlugin extends Plugin {
159 }) 159 })
160 160
161 this.player.one('ended', () => { 161 this.player.one('ended', () => {
162 const currentTime = Math.floor(this.player.duration()) 162 const currentTime = Math.round(this.player.duration())
163 lastCurrentTime = currentTime 163 lastCurrentTime = currentTime
164 164
165 this.notifyUserIsWatching(currentTime, lastViewEvent) 165 this.notifyUserIsWatching(currentTime, lastViewEvent)
@@ -168,7 +168,7 @@ class PeerTubePlugin extends Plugin {
168 }) 168 })
169 169
170 this.videoViewInterval = setInterval(() => { 170 this.videoViewInterval = setInterval(() => {
171 const currentTime = Math.floor(this.player.currentTime()) 171 const currentTime = Math.round(this.player.currentTime())
172 172
173 // No need to update 173 // No need to update
174 if (currentTime === lastCurrentTime) return 174 if (currentTime === lastCurrentTime) return