aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/request/request-video-event-interface.ts
blob: 3ed03339a4ff192997e40ba076ba021831c05e38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import * as Sequelize from 'sequelize'

import { VideoInstance } from '../video'
import { PodInstance } from '../pod'

import { RequestVideoEventType } from '../../../shared/models/request-scheduler.model'

export type RequestsVideoEventGrouped = {
  [ podId: number ]: {
    id: number
    type: RequestVideoEventType
    count: number
    video: VideoInstance
    pod: PodInstance
  }[]
}

export namespace RequestVideoEventMethods {
  export type CountTotalRequestsCallback = (err: Error, total: number) => void
  export type CountTotalRequests = (callback: CountTotalRequestsCallback) => void

  export type ListWithLimitAndRandomCallback = (err: Error, requestsGrouped?: RequestsVideoEventGrouped) => void
  export type ListWithLimitAndRandom = (limitPods: number, limitRequestsPerPod: number, callback: ListWithLimitAndRandomCallback) => void

  export type RemoveByRequestIdsAndPodCallback = () => void
  export type RemoveByRequestIdsAndPod = (ids: number[], podId: number, callback: RemoveByRequestIdsAndPodCallback) => void

  export type RemoveAllCallback = () => void
  export type RemoveAll = (callback: RemoveAllCallback) => void
}

export interface RequestVideoEventClass {
  countTotalRequests: RequestVideoEventMethods.CountTotalRequests
  listWithLimitAndRandom: RequestVideoEventMethods.ListWithLimitAndRandom
  removeByRequestIdsAndPod: RequestVideoEventMethods.RemoveByRequestIdsAndPod
  removeAll: RequestVideoEventMethods.RemoveAll
}

export interface RequestVideoEventAttributes {
  type: RequestVideoEventType
  count: number
}

export interface RequestVideoEventInstance extends RequestVideoEventClass, RequestVideoEventAttributes, Sequelize.Instance<RequestVideoEventAttributes> {
  id: number

  Video: VideoInstance
}

export interface RequestVideoEventModel extends RequestVideoEventClass, Sequelize.Model<RequestVideoEventInstance, RequestVideoEventAttributes> {}