]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/pod/pod-interface.ts
Formated -> Formatted
[github/Chocobozzz/PeerTube.git] / server / models / pod / pod-interface.ts
CommitLineData
e02643f3 1import * as Sequelize from 'sequelize'
6fcd19ba 2import * as Promise from 'bluebird'
e02643f3 3
69818c93 4// Don't use barrel, import just what we need
0aef76c4 5import { Pod as FormattedPod } from '../../../shared/models/pods/pod.model'
69818c93 6
e02643f3 7export namespace PodMethods {
0aef76c4 8 export type ToFormattedJSON = (this: PodInstance) => FormattedPod
e02643f3 9
6fcd19ba 10 export type CountAll = () => Promise<number>
69818c93 11
6fcd19ba 12 export type IncrementScores = (ids: number[], value: number) => Promise<[ number, PodInstance[] ]>
69818c93 13
6fcd19ba 14 export type List = () => Promise<PodInstance[]>
69818c93 15
6fcd19ba 16 export type ListAllIds = (transaction: Sequelize.Transaction) => Promise<number[]>
69818c93 17
6fcd19ba 18 export type ListRandomPodIdsWithRequest = (limit: number, tableWithPods: string, tableWithPodsJoins: string) => Promise<number[]>
69818c93 19
6fcd19ba 20 export type ListBadPods = () => Promise<PodInstance[]>
69818c93 21
6fcd19ba 22 export type Load = (id: number) => Promise<PodInstance>
69818c93 23
6fcd19ba 24 export type LoadByHost = (host: string) => Promise<PodInstance>
69818c93 25
6fcd19ba 26 export type RemoveAll = () => Promise<number>
69818c93
C
27
28 export type UpdatePodsScore = (goodPods: number[], badPods: number[]) => void
e02643f3
C
29}
30
31export interface PodClass {
32 countAll: PodMethods.CountAll
33 incrementScores: PodMethods.IncrementScores
34 list: PodMethods.List
35 listAllIds: PodMethods.ListAllIds
36 listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest
37 listBadPods: PodMethods.ListBadPods
38 load: PodMethods.Load
39 loadByHost: PodMethods.LoadByHost
40 removeAll: PodMethods.RemoveAll
41 updatePodsScore: PodMethods.UpdatePodsScore
42}
43
44export interface PodAttributes {
45 host?: string
46 publicKey?: string
47 score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
48 email?: string
49}
50
51export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> {
52 id: number
53 createdAt: Date
54 updatedAt: Date
55
0aef76c4 56 toFormattedJSON: PodMethods.ToFormattedJSON,
e02643f3
C
57}
58
59export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}