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.ts21
1 files changed, 12 insertions, 9 deletions
diff --git a/server/lib/request/request-video-event-scheduler.ts b/server/lib/request/request-video-event-scheduler.ts
index bde50b1d3..9da82585e 100644
--- a/server/lib/request/request-video-event-scheduler.ts
+++ b/server/lib/request/request-video-event-scheduler.ts
@@ -1,3 +1,5 @@
1import * as Sequelize from 'sequelize'
2
1import { database as db } from '../../initializers/database' 3import { database as db } from '../../initializers/database'
2import { BaseRequestScheduler } from './base-request-scheduler' 4import { BaseRequestScheduler } from './base-request-scheduler'
3import { 5import {
@@ -6,6 +8,13 @@ import {
6 REQUEST_VIDEO_EVENT_ENDPOINT 8 REQUEST_VIDEO_EVENT_ENDPOINT
7} from '../../initializers' 9} from '../../initializers'
8 10
11export type RequestVideoEventSchedulerOptions = {
12 type: string
13 videoId: string
14 count?: number
15 transaction?: Sequelize.Transaction
16}
17
9class RequestVideoEventScheduler extends BaseRequestScheduler { 18class RequestVideoEventScheduler extends BaseRequestScheduler {
10 constructor () { 19 constructor () {
11 super() 20 super()
@@ -25,7 +34,7 @@ class RequestVideoEventScheduler extends BaseRequestScheduler {
25 return db.RequestVideoEvent 34 return db.RequestVideoEvent
26 } 35 }
27 36
28 buildRequestObjects (eventsToProcess) { 37 buildRequestObjects (eventsToProcess: { [ toPodId: number ]: any }[]) {
29 const requestsToMakeGrouped = {} 38 const requestsToMakeGrouped = {}
30 39
31 /* Example: 40 /* Example:
@@ -87,16 +96,10 @@ class RequestVideoEventScheduler extends BaseRequestScheduler {
87 return requestsToMakeGrouped 96 return requestsToMakeGrouped
88 } 97 }
89 98
90 // { type, videoId, count?, transaction? } 99 createRequest ({ type, videoId, count, transaction }: RequestVideoEventSchedulerOptions, callback: (err: Error) => void) {
91 createRequest (options, callback) {
92 const type = options.type
93 const videoId = options.videoId
94 const transaction = options.transaction
95 let count = options.count
96
97 if (count === undefined) count = 1 100 if (count === undefined) count = 1
98 101
99 const dbRequestOptions: { transaction?: any } = {} 102 const dbRequestOptions: Sequelize.CreateOptions = {}
100 if (transaction) dbRequestOptions.transaction = transaction 103 if (transaction) dbRequestOptions.transaction = transaction
101 104
102 const createQuery = { 105 const createQuery = {