diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
commit | 69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch) | |
tree | ad199a18ec3c322460d6f9523fc383ee562554e0 /server/lib/request/request-video-qadu-scheduler.ts | |
parent | 4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff) | |
download | PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip |
Type functions
Diffstat (limited to 'server/lib/request/request-video-qadu-scheduler.ts')
-rw-r--r-- | server/lib/request/request-video-qadu-scheduler.ts | 21 |
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
1 | import { database as db } from '../../initializers/database' | 3 | import { database as db } from '../../initializers/database' |
2 | import { BaseRequestScheduler } from './base-request-scheduler' | 4 | import { BaseRequestScheduler } from './base-request-scheduler' |
3 | import { logger } from '../../helpers' | 5 | import { 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 | ||
13 | export type RequestVideoQaduSchedulerOptions = { | ||
14 | type: string | ||
15 | videoId: string | ||
16 | transaction?: Sequelize.Transaction | ||
17 | } | ||
18 | |||
11 | class RequestVideoQaduScheduler extends BaseRequestScheduler { | 19 | class 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 = [] |