]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/pod/pod-interface.ts
Add follow tabs
[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'
8a02bd04 6import { ResultList } from '../../../shared/models/result-list.model'
69818c93 7
e02643f3 8export namespace PodMethods {
0aef76c4 9 export type ToFormattedJSON = (this: PodInstance) => FormattedPod
e02643f3 10
6fcd19ba 11 export type CountAll = () => Promise<number>
69818c93 12
6fcd19ba 13 export type IncrementScores = (ids: number[], value: number) => Promise<[ number, PodInstance[] ]>
69818c93 14
6fcd19ba 15 export type List = () => Promise<PodInstance[]>
69818c93 16
8a02bd04
C
17 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<PodInstance> >
18
6fcd19ba 19 export type ListAllIds = (transaction: Sequelize.Transaction) => Promise<number[]>
69818c93 20
6fcd19ba 21 export type ListRandomPodIdsWithRequest = (limit: number, tableWithPods: string, tableWithPodsJoins: string) => Promise<number[]>
69818c93 22
6fcd19ba 23 export type ListBadPods = () => Promise<PodInstance[]>
69818c93 24
6fcd19ba 25 export type Load = (id: number) => Promise<PodInstance>
69818c93 26
6fcd19ba 27 export type LoadByHost = (host: string) => Promise<PodInstance>
69818c93 28
6fcd19ba 29 export type RemoveAll = () => Promise<number>
69818c93
C
30
31 export type UpdatePodsScore = (goodPods: number[], badPods: number[]) => void
e02643f3
C
32}
33
34export interface PodClass {
35 countAll: PodMethods.CountAll
36 incrementScores: PodMethods.IncrementScores
37 list: PodMethods.List
8a02bd04 38 listForApi: PodMethods.ListForApi
e02643f3
C
39 listAllIds: PodMethods.ListAllIds
40 listRandomPodIdsWithRequest: PodMethods.ListRandomPodIdsWithRequest
41 listBadPods: PodMethods.ListBadPods
42 load: PodMethods.Load
43 loadByHost: PodMethods.LoadByHost
44 removeAll: PodMethods.RemoveAll
45 updatePodsScore: PodMethods.UpdatePodsScore
46}
47
48export interface PodAttributes {
556ddc31 49 id?: number
e02643f3 50 host?: string
e02643f3 51 score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
e02643f3
C
52}
53
54export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> {
e02643f3
C
55 createdAt: Date
56 updatedAt: Date
57
0aef76c4 58 toFormattedJSON: PodMethods.ToFormattedJSON,
e02643f3
C
59}
60
61export interface PodModel extends PodClass, Sequelize.Model<PodInstance, PodAttributes> {}