diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-09 10:11:20 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-11-09 15:00:31 +0100 |
commit | 51353d9a035fb6b81f903a8b5f391292841649fd (patch) | |
tree | 75acb6eea5e043bf2e15a6a5a92e9a3c5967b156 /client | |
parent | 221ee1adc916684d4881d2a9c4c01954dcde986e (diff) | |
download | PeerTube-51353d9a035fb6b81f903a8b5f391292841649fd.tar.gz PeerTube-51353d9a035fb6b81f903a8b5f391292841649fd.tar.zst PeerTube-51353d9a035fb6b81f903a8b5f391292841649fd.zip |
Refactor video views
Introduce viewers attribute for live videos
Count views for live videos
Reduce delay to see the viewer update for lives
Add ability to configure video views buffer interval and view ip
expiration
Diffstat (limited to 'client')
4 files changed, 9 insertions, 5 deletions
diff --git a/client/src/app/+admin/system/jobs/jobs.component.ts b/client/src/app/+admin/system/jobs/jobs.component.ts index b12d7f80a..2cf1bff7a 100644 --- a/client/src/app/+admin/system/jobs/jobs.component.ts +++ b/client/src/app/+admin/system/jobs/jobs.component.ts | |||
@@ -36,7 +36,7 @@ export class JobsComponent extends RestTable implements OnInit { | |||
36 | 'video-live-ending', | 36 | 'video-live-ending', |
37 | 'video-redundancy', | 37 | 'video-redundancy', |
38 | 'video-transcoding', | 38 | 'video-transcoding', |
39 | 'videos-views', | 39 | 'videos-views-stats', |
40 | 'move-to-object-storage' | 40 | 'move-to-object-storage' |
41 | ] | 41 | ] |
42 | 42 | ||
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 5ca9d5fa9..fd61bcbf0 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts | |||
@@ -658,7 +658,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
658 | return this.peertubeSocket.getLiveVideosObservable() | 658 | return this.peertubeSocket.getLiveVideosObservable() |
659 | .subscribe(({ type, payload }) => { | 659 | .subscribe(({ type, payload }) => { |
660 | if (type === 'state-change') return this.handleLiveStateChange(payload.state) | 660 | if (type === 'state-change') return this.handleLiveStateChange(payload.state) |
661 | if (type === 'views-change') return this.handleLiveViewsChange(payload.views) | 661 | if (type === 'views-change') return this.handleLiveViewsChange(payload.viewers) |
662 | }) | 662 | }) |
663 | } | 663 | } |
664 | 664 | ||
@@ -677,7 +677,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
677 | this.loadVideo(videoUUID) | 677 | this.loadVideo(videoUUID) |
678 | } | 678 | } |
679 | 679 | ||
680 | private handleLiveViewsChange (newViews: number) { | 680 | private handleLiveViewsChange (newViewers: number) { |
681 | if (!this.video) { | 681 | if (!this.video) { |
682 | console.error('Cannot update video live views because video is no defined.') | 682 | console.error('Cannot update video live views because video is no defined.') |
683 | return | 683 | return |
@@ -685,7 +685,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
685 | 685 | ||
686 | console.log('Updating live views.') | 686 | console.log('Updating live views.') |
687 | 687 | ||
688 | this.video.views = newViews | 688 | this.video.viewers = newViewers |
689 | } | 689 | } |
690 | 690 | ||
691 | private initHotkeys () { | 691 | private initHotkeys () { |
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index b11316471..472a8c810 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts | |||
@@ -57,6 +57,9 @@ export class Video implements VideoServerModel { | |||
57 | url: string | 57 | url: string |
58 | 58 | ||
59 | views: number | 59 | views: number |
60 | // If live | ||
61 | viewers?: number | ||
62 | |||
60 | likes: number | 63 | likes: number |
61 | dislikes: number | 64 | dislikes: number |
62 | nsfw: boolean | 65 | nsfw: boolean |
@@ -150,6 +153,7 @@ export class Video implements VideoServerModel { | |||
150 | this.url = hash.url | 153 | this.url = hash.url |
151 | 154 | ||
152 | this.views = hash.views | 155 | this.views = hash.views |
156 | this.viewers = hash.viewers | ||
153 | this.likes = hash.likes | 157 | this.likes = hash.likes |
154 | this.dislikes = hash.dislikes | 158 | this.dislikes = hash.dislikes |
155 | 159 | ||
diff --git a/client/src/app/shared/shared-video/video-views-counter.component.html b/client/src/app/shared/shared-video/video-views-counter.component.html index a6679f74d..b19c8b137 100644 --- a/client/src/app/shared/shared-video/video-views-counter.component.html +++ b/client/src/app/shared/shared-video/video-views-counter.component.html | |||
@@ -4,6 +4,6 @@ | |||
4 | </ng-container> | 4 | </ng-container> |
5 | 5 | ||
6 | <ng-container i18n *ngIf="video.isLive"> | 6 | <ng-container i18n *ngIf="video.isLive"> |
7 | {video.views, plural, =1 {1 viewer} other {{{ video.views | myNumberFormatter }} viewers}} | 7 | {video.viewers, plural, =1 {1 viewer} other {{{ video.viewers | myNumberFormatter }} viewers}} |
8 | </ng-container> | 8 | </ng-container> |
9 | </span> | 9 | </span> |