aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/models/request/request-video-event-interface.ts
blob: 26cabe3ba86baadf57b66e25f4965f2bf4e50b35 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                      
                                   
 
                                                                                              

                                                        
 

                                                                                      


                                         
                               





                        
                                           
                                                        
 
                                                                                                                             
 
                                                                                          
 
                                             

 
                                                                                                                            






                                                                             
                             


               

                                                                                                                
            

                      

 

                                                                                                            
import * as Sequelize from 'sequelize'
import * as Promise from 'bluebird'

import { AbstractRequestClass, AbstractRequestToPodClass } from './abstract-request-interface'
import { VideoInstance } from '../video/video-interface'
import { PodInstance } from '../pod/pod-interface'

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 CountTotalRequests = () => Promise<number>

  export type ListWithLimitAndRandom = (limitPods: number, limitRequestsPerPod: number) => Promise<RequestsVideoEventGrouped>

  export type RemoveByRequestIdsAndPod = (ids: number[], podId: number) => Promise<number>

  export type RemoveAll = () => Promise<void>
}

export interface RequestVideoEventClass extends AbstractRequestClass<RequestsVideoEventGrouped>, AbstractRequestToPodClass {
  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> {}