aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/request/request-video-qadu-scheduler.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/request/request-video-qadu-scheduler.ts')
-rw-r--r--server/lib/request/request-video-qadu-scheduler.ts21
1 files changed, 12 insertions, 9 deletions
diff --git a/server/lib/request/request-video-qadu-scheduler.ts b/server/lib/request/request-video-qadu-scheduler.ts
index dab526088..436fd8e50 100644
--- a/server/lib/request/request-video-qadu-scheduler.ts
+++ b/server/lib/request/request-video-qadu-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 { logger } from '../../helpers' 5import { logger } from '../../helpers'
@@ -8,6 +10,12 @@ import {
8 REQUEST_VIDEO_QADU_TYPES 10 REQUEST_VIDEO_QADU_TYPES
9} from '../../initializers' 11} from '../../initializers'
10 12
13export type RequestVideoQaduSchedulerOptions = {
14 type: string
15 videoId: string
16 transaction?: Sequelize.Transaction
17}
18
11class RequestVideoQaduScheduler extends BaseRequestScheduler { 19class RequestVideoQaduScheduler extends BaseRequestScheduler {
12 constructor () { 20 constructor () {
13 super() 21 super()
@@ -27,7 +35,7 @@ class RequestVideoQaduScheduler extends BaseRequestScheduler {
27 return db.RequestVideoQadu 35 return db.RequestVideoQadu
28 } 36 }
29 37
30 buildRequestObjects (requests) { 38 buildRequestObjects (requests: { [ toPodId: number ]: any }[]) {
31 const requestsToMakeGrouped = {} 39 const requestsToMakeGrouped = {}
32 40
33 Object.keys(requests).forEach(toPodId => { 41 Object.keys(requests).forEach(toPodId => {
@@ -96,17 +104,12 @@ class RequestVideoQaduScheduler extends BaseRequestScheduler {
96 return requestsToMakeGrouped 104 return requestsToMakeGrouped
97 } 105 }
98 106
99 // { type, videoId, transaction? } 107 createRequest ({ type, videoId, transaction }: RequestVideoQaduSchedulerOptions, callback: (err: Error) => void) {
100 createRequest (options, callback) { 108 const dbRequestOptions: Sequelize.BulkCreateOptions = {}
101 const type = options.type
102 const videoId = options.videoId
103 const transaction = options.transaction
104
105 const dbRequestOptions: { transaction?: any } = {}
106 if (transaction) dbRequestOptions.transaction = transaction 109 if (transaction) dbRequestOptions.transaction = transaction
107 110
108 // Send the update to all our friends 111 // Send the update to all our friends
109 db.Pod.listAllIds(options.transaction, function (err, podIds) { 112 db.Pod.listAllIds(transaction, function (err, podIds) {
110 if (err) return callback(err) 113 if (err) return callback(err)
111 114
112 const queries = [] 115 const queries = []