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-event-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-event-scheduler.ts')
-rw-r--r-- | server/lib/request/request-video-event-scheduler.ts | 21 |
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 @@ | |||
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 { | 5 | import { |
@@ -6,6 +8,13 @@ import { | |||
6 | REQUEST_VIDEO_EVENT_ENDPOINT | 8 | REQUEST_VIDEO_EVENT_ENDPOINT |
7 | } from '../../initializers' | 9 | } from '../../initializers' |
8 | 10 | ||
11 | export type RequestVideoEventSchedulerOptions = { | ||
12 | type: string | ||
13 | videoId: string | ||
14 | count?: number | ||
15 | transaction?: Sequelize.Transaction | ||
16 | } | ||
17 | |||
9 | class RequestVideoEventScheduler extends BaseRequestScheduler { | 18 | class 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 = { |