aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-09 10:11:20 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-11-09 15:00:31 +0100
commit51353d9a035fb6b81f903a8b5f391292841649fd (patch)
tree75acb6eea5e043bf2e15a6a5a92e9a3c5967b156 /shared
parent221ee1adc916684d4881d2a9c4c01954dcde986e (diff)
downloadPeerTube-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 'shared')
-rw-r--r--shared/extra-utils/server/jobs.ts4
-rw-r--r--shared/models/activitypub/activity.ts4
-rw-r--r--shared/models/server/job.model.ts2
-rw-r--r--shared/models/videos/live/live-video-event-payload.model.ts4
-rw-r--r--shared/models/videos/video.model.ts3
5 files changed, 12 insertions, 5 deletions
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts
index 79b8c3183..afaaa5cd6 100644
--- a/shared/extra-utils/server/jobs.ts
+++ b/shared/extra-utils/server/jobs.ts
@@ -1,5 +1,5 @@
1 1
2import { JobState } from '../../models' 2import { JobState, JobType } from '../../models'
3import { wait } from '../miscs' 3import { wait } from '../miscs'
4import { PeerTubeServer } from './server' 4import { PeerTubeServer } from './server'
5 5
@@ -16,7 +16,7 @@ async function waitJobs (serversArg: PeerTubeServer[] | PeerTubeServer, skipDela
16 const states: JobState[] = [ 'waiting', 'active' ] 16 const states: JobState[] = [ 'waiting', 'active' ]
17 if (!skipDelayed) states.push('delayed') 17 if (!skipDelayed) states.push('delayed')
18 18
19 const repeatableJobs = [ 'videos-views', 'activitypub-cleaner' ] 19 const repeatableJobs: JobType[] = [ 'videos-views-stats', 'activitypub-cleaner' ]
20 let pendingRequests: boolean 20 let pendingRequests: boolean
21 21
22 function tasksBuilder () { 22 function tasksBuilder () {
diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts
index 548d8858e..d6284e283 100644
--- a/shared/models/activitypub/activity.ts
+++ b/shared/models/activitypub/activity.ts
@@ -6,7 +6,6 @@ import { DislikeObject } from './objects/dislike-object'
6import { APObject } from './objects/object.model' 6import { APObject } from './objects/object.model'
7import { PlaylistObject } from './objects/playlist-object' 7import { PlaylistObject } from './objects/playlist-object'
8import { VideoCommentObject } from './objects/video-comment-object' 8import { VideoCommentObject } from './objects/video-comment-object'
9import { ViewObject } from './objects/view-object'
10 9
11export type Activity = 10export type Activity =
12 ActivityCreate | 11 ActivityCreate |
@@ -53,7 +52,7 @@ export interface BaseActivity {
53 52
54export interface ActivityCreate extends BaseActivity { 53export interface ActivityCreate extends BaseActivity {
55 type: 'Create' 54 type: 'Create'
56 object: VideoObject | AbuseObject | ViewObject | DislikeObject | VideoCommentObject | CacheFileObject | PlaylistObject 55 object: VideoObject | AbuseObject | DislikeObject | VideoCommentObject | CacheFileObject | PlaylistObject
57} 56}
58 57
59export interface ActivityUpdate extends BaseActivity { 58export interface ActivityUpdate extends BaseActivity {
@@ -100,6 +99,7 @@ export interface ActivityView extends BaseActivity {
100 type: 'View' 99 type: 'View'
101 actor: string 100 actor: string
102 object: APObject 101 object: APObject
102 expires: string
103} 103}
104 104
105export interface ActivityDislike extends BaseActivity { 105export interface ActivityDislike extends BaseActivity {
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts
index 12e0fcf85..6da2753b3 100644
--- a/shared/models/server/job.model.ts
+++ b/shared/models/server/job.model.ts
@@ -14,7 +14,7 @@ export type JobType =
14 | 'video-transcoding' 14 | 'video-transcoding'
15 | 'email' 15 | 'email'
16 | 'video-import' 16 | 'video-import'
17 | 'videos-views' 17 | 'videos-views-stats'
18 | 'activitypub-refresher' 18 | 'activitypub-refresher'
19 | 'video-redundancy' 19 | 'video-redundancy'
20 | 'video-live-ending' 20 | 'video-live-ending'
diff --git a/shared/models/videos/live/live-video-event-payload.model.ts b/shared/models/videos/live/live-video-event-payload.model.ts
index 6cd7540e8..1a9ac512c 100644
--- a/shared/models/videos/live/live-video-event-payload.model.ts
+++ b/shared/models/videos/live/live-video-event-payload.model.ts
@@ -2,5 +2,9 @@ import { VideoState } from '../video-state.enum'
2 2
3export interface LiveVideoEventPayload { 3export interface LiveVideoEventPayload {
4 state?: VideoState 4 state?: VideoState
5
6 // FIXME: deprecated in 4.0 in favour of viewers
5 views?: number 7 views?: number
8
9 viewers?: number
6} 10}
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts
index 26cb595e7..8d223cded 100644
--- a/shared/models/videos/video.model.ts
+++ b/shared/models/videos/video.model.ts
@@ -39,6 +39,9 @@ export interface Video {
39 url: string 39 url: string
40 40
41 views: number 41 views: number
42 // If live
43 viewers?: number
44
42 likes: number 45 likes: number
43 dislikes: number 46 dislikes: number
44 nsfw: boolean 47 nsfw: boolean