diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
commit | 69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch) | |
tree | ad199a18ec3c322460d6f9523fc383ee562554e0 /server/models/request-video-qadu.ts | |
parent | 4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff) | |
download | PeerTube-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.ts | 17 |
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 @@ | |||
12 | import { values } from 'lodash' | 12 | import { values } from 'lodash' |
13 | import * as Sequelize from 'sequelize' | 13 | import * as Sequelize from 'sequelize' |
14 | 14 | ||
15 | import { database as db } from '../initializers/database' | ||
15 | import { REQUEST_VIDEO_QADU_TYPES } from '../initializers' | 16 | import { REQUEST_VIDEO_QADU_TYPES } from '../initializers' |
16 | |||
17 | import { addMethodsToModel } from './utils' | 17 | import { addMethodsToModel } from './utils' |
18 | import { | 18 | import { |
19 | RequestVideoQaduClass, | 19 | RequestVideoQaduClass, |
@@ -83,15 +83,16 @@ function associate (models) { | |||
83 | }) | 83 | }) |
84 | } | 84 | } |
85 | 85 | ||
86 | countTotalRequests = function (callback) { | 86 | countTotalRequests = 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 | ||
91 | listWithLimitAndRandom = function (limitPods, limitRequestsPerPod, callback) { | 91 | listWithLimitAndRandom = 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 | ||
125 | removeByRequestIdsAndPod = function (ids, podId, callback) { | 126 | removeByRequestIdsAndPod = 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 | ||
138 | removeAll = function (callback) { | 139 | removeAll = 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 | ||
145 | function groupAndTruncateRequests (requests, limitRequestsPerPod) { | 146 | function groupAndTruncateRequests (requests: RequestVideoQaduInstance[], limitRequestsPerPod: number) { |
146 | const requestsGrouped = {} | 147 | const requestsGrouped = {} |
147 | 148 | ||
148 | requests.forEach(function (request) { | 149 | requests.forEach(function (request) { |