aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/request/request-video-event-scheduler.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/request/request-video-event-scheduler.ts')
-rw-r--r--server/lib/request/request-video-event-scheduler.ts22
1 files changed, 15 insertions, 7 deletions
diff --git a/server/lib/request/request-video-event-scheduler.ts b/server/lib/request/request-video-event-scheduler.ts
index d4d714c02..8a008c51b 100644
--- a/server/lib/request/request-video-event-scheduler.ts
+++ b/server/lib/request/request-video-event-scheduler.ts
@@ -1,14 +1,14 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2
3import { database as db } from '../../initializers/database' 3import { database as db } from '../../initializers/database'
4import { AbstractRequestScheduler } from './abstract-request-scheduler' 4import { AbstractRequestScheduler, RequestsObjects } from './abstract-request-scheduler'
5import { 5import {
6 REQUESTS_VIDEO_EVENT_LIMIT_PODS, 6 REQUESTS_VIDEO_EVENT_LIMIT_PODS,
7 REQUESTS_VIDEO_EVENT_LIMIT_PER_POD, 7 REQUESTS_VIDEO_EVENT_LIMIT_PER_POD,
8 REQUEST_VIDEO_EVENT_ENDPOINT 8 REQUEST_VIDEO_EVENT_ENDPOINT
9} from '../../initializers' 9} from '../../initializers'
10import { RequestsVideoEventGrouped } from '../../models' 10import { RequestsVideoEventGrouped } from '../../models'
11import { RequestVideoEventType } from '../../../shared' 11import { RequestVideoEventType, RemoteVideoEventRequest, RemoteVideoEventType } from '../../../shared'
12 12
13export type RequestVideoEventSchedulerOptions = { 13export type RequestVideoEventSchedulerOptions = {
14 type: RequestVideoEventType 14 type: RequestVideoEventType
@@ -36,8 +36,8 @@ class RequestVideoEventScheduler extends AbstractRequestScheduler<RequestsVideoE
36 return db.RequestVideoEvent 36 return db.RequestVideoEvent
37 } 37 }
38 38
39 buildRequestObjects (eventRequests: RequestsVideoEventGrouped) { 39 buildRequestsObjects (eventRequests: RequestsVideoEventGrouped) {
40 const requestsToMakeGrouped = {} 40 const requestsToMakeGrouped: RequestsObjects<RemoteVideoEventRequest> = {}
41 41
42 /* Example: 42 /* Example:
43 { 43 {
@@ -47,7 +47,15 @@ class RequestVideoEventScheduler extends AbstractRequestScheduler<RequestsVideoE
47 } 47 }
48 } 48 }
49 */ 49 */
50 const eventsPerVideoPerPod = {} 50 const eventsPerVideoPerPod: {
51 [ podId: string ]: {
52 [ videoRemoteId: string ]: {
53 views?: number
54 likes?: number
55 dislikes?: number
56 }
57 }
58 } = {}
51 59
52 // We group video events per video and per pod 60 // We group video events per video and per pod
53 // We add the counts of the same event types 61 // We add the counts of the same event types
@@ -87,8 +95,8 @@ class RequestVideoEventScheduler extends AbstractRequestScheduler<RequestsVideoE
87 requestsToMakeGrouped[toPodId].datas.push({ 95 requestsToMakeGrouped[toPodId].datas.push({
88 data: { 96 data: {
89 remoteId, 97 remoteId,
90 eventType, 98 eventType: eventType as RemoteVideoEventType,
91 count: eventsForVideo[eventType] 99 count: +eventsForVideo[eventType]
92 } 100 }
93 }) 101 })
94 }) 102 })