From 69818c9394366b954b6ba3bd697bd9d2b09f2a16 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 10 Jun 2017 22:15:25 +0200 Subject: Type functions --- server/lib/request/request-video-event-scheduler.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'server/lib/request/request-video-event-scheduler.ts') 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 @@ +import * as Sequelize from 'sequelize' + import { database as db } from '../../initializers/database' import { BaseRequestScheduler } from './base-request-scheduler' import { @@ -6,6 +8,13 @@ import { REQUEST_VIDEO_EVENT_ENDPOINT } from '../../initializers' +export type RequestVideoEventSchedulerOptions = { + type: string + videoId: string + count?: number + transaction?: Sequelize.Transaction +} + class RequestVideoEventScheduler extends BaseRequestScheduler { constructor () { super() @@ -25,7 +34,7 @@ class RequestVideoEventScheduler extends BaseRequestScheduler { return db.RequestVideoEvent } - buildRequestObjects (eventsToProcess) { + buildRequestObjects (eventsToProcess: { [ toPodId: number ]: any }[]) { const requestsToMakeGrouped = {} /* Example: @@ -87,16 +96,10 @@ class RequestVideoEventScheduler extends BaseRequestScheduler { return requestsToMakeGrouped } - // { type, videoId, count?, transaction? } - createRequest (options, callback) { - const type = options.type - const videoId = options.videoId - const transaction = options.transaction - let count = options.count - + createRequest ({ type, videoId, count, transaction }: RequestVideoEventSchedulerOptions, callback: (err: Error) => void) { if (count === undefined) count = 1 - const dbRequestOptions: { transaction?: any } = {} + const dbRequestOptions: Sequelize.CreateOptions = {} if (transaction) dbRequestOptions.transaction = transaction const createQuery = { -- cgit v1.2.3