aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/request-video-qadu.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
commit69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch)
treead199a18ec3c322460d6f9523fc383ee562554e0 /server/models/request-video-qadu.ts
parent4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff)
downloadPeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst
PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip
Type functions
Diffstat (limited to 'server/models/request-video-qadu.ts')
-rw-r--r--server/models/request-video-qadu.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/server/models/request-video-qadu.ts b/server/models/request-video-qadu.ts
index e914e06cd..38627ad55 100644
--- a/server/models/request-video-qadu.ts
+++ b/server/models/request-video-qadu.ts
@@ -12,8 +12,8 @@
12import { values } from 'lodash' 12import { values } from 'lodash'
13import * as Sequelize from 'sequelize' 13import * as Sequelize from 'sequelize'
14 14
15import { database as db } from '../initializers/database'
15import { REQUEST_VIDEO_QADU_TYPES } from '../initializers' 16import { REQUEST_VIDEO_QADU_TYPES } from '../initializers'
16
17import { addMethodsToModel } from './utils' 17import { addMethodsToModel } from './utils'
18import { 18import {
19 RequestVideoQaduClass, 19 RequestVideoQaduClass,
@@ -83,15 +83,16 @@ function associate (models) {
83 }) 83 })
84} 84}
85 85
86countTotalRequests = function (callback) { 86countTotalRequests = function (callback: RequestVideoQaduMethods.CountTotalRequestsCallback) {
87 const query = {} 87 const query = {}
88 return RequestVideoQadu.count(query).asCallback(callback) 88 return RequestVideoQadu.count(query).asCallback(callback)
89} 89}
90 90
91listWithLimitAndRandom = function (limitPods, limitRequestsPerPod, callback) { 91listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: number, callback: RequestVideoQaduMethods.ListWithLimitAndRandomCallback) {
92 const Pod = RequestVideoQadu['sequelize'].models.Pod 92 const Pod = db.Pod
93 const tableJoin = ''
93 94
94 Pod.listRandomPodIdsWithRequest(limitPods, 'RequestVideoQadus', function (err, podIds) { 95 Pod.listRandomPodIdsWithRequest(limitPods, 'RequestVideoQadus', tableJoin, function (err, podIds) {
95 if (err) return callback(err) 96 if (err) return callback(err)
96 97
97 // We don't have friends that have requests 98 // We don't have friends that have requests
@@ -122,7 +123,7 @@ listWithLimitAndRandom = function (limitPods, limitRequestsPerPod, callback) {
122 }) 123 })
123} 124}
124 125
125removeByRequestIdsAndPod = function (ids, podId, callback) { 126removeByRequestIdsAndPod = function (ids: number[], podId: number, callback: RequestVideoQaduMethods.RemoveByRequestIdsAndPodCallback) {
126 const query = { 127 const query = {
127 where: { 128 where: {
128 id: { 129 id: {
@@ -135,14 +136,14 @@ removeByRequestIdsAndPod = function (ids, podId, callback) {
135 RequestVideoQadu.destroy(query).asCallback(callback) 136 RequestVideoQadu.destroy(query).asCallback(callback)
136} 137}
137 138
138removeAll = function (callback) { 139removeAll = function (callback: RequestVideoQaduMethods.RemoveAllCallback) {
139 // Delete all requests 140 // Delete all requests
140 RequestVideoQadu.truncate({ cascade: true }).asCallback(callback) 141 RequestVideoQadu.truncate({ cascade: true }).asCallback(callback)
141} 142}
142 143
143// --------------------------------------------------------------------------- 144// ---------------------------------------------------------------------------
144 145
145function groupAndTruncateRequests (requests, limitRequestsPerPod) { 146function groupAndTruncateRequests (requests: RequestVideoQaduInstance[], limitRequestsPerPod: number) {
146 const requestsGrouped = {} 147 const requestsGrouped = {}
147 148
148 requests.forEach(function (request) { 149 requests.forEach(function (request) {