1 import * as Sequelize from 'sequelize'
2 import * as Promise from 'bluebird'
4 // Don't use barrel, import just what we need
5 import { Pod as FormattedPod } from '../../../shared/models/pods/pod.model'
7 export namespace PodMethods {
8 export type ToFormattedJSON = (this: PodInstance) => FormattedPod
10 export type CountAll = () => Promise<number>
12 export type IncrementScores = (ids: number[], value: number) => Promise<[ number, PodInstance[] ]>
14 export type List = () => Promise<PodInstance[]>
16 export type ListAllIds = (transaction: Sequelize.Transaction) => Promise<number[]>
18 export type ListRandomPodIdsWithRequest = (limit: number, tableWithPods: string, tableWithPodsJoins: string) => Promise<number[]>
20 export type ListBadPods = () => Promise<PodInstance[]>
22 export type Load = (id: number) => Promise<PodInstance>
24 export type LoadByHost = (host: string) => Promise<PodInstance>
26 export type RemoveAll = () => Promise<number>
28 export type UpdatePodsScore = (goodPods: number[], badPods: number[]) => void
31 export interface PodClass {
32 countAll: PodMethods.CountAll
33 incrementScores: PodMethods.IncrementScores
35 listAllIds: PodMethods.ListAllIds
36 listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest
37 listBadPods: PodMethods.ListBadPods
39 loadByHost: PodMethods.LoadByHost
40 removeAll: PodMethods.RemoveAll
41 updatePodsScore: PodMethods.UpdatePodsScore
44 export interface PodAttributes {
48 score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
52 export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> {
56 toFormattedJSON: PodMethods.ToFormattedJSON,
59 export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}