diff options
Diffstat (limited to 'server/models/request/request-video-qadu.ts')
-rw-r--r-- | server/models/request/request-video-qadu.ts | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/server/models/request/request-video-qadu.ts b/server/models/request/request-video-qadu.ts index da62239f5..74e28f129 100644 --- a/server/models/request/request-video-qadu.ts +++ b/server/models/request/request-video-qadu.ts | |||
@@ -16,7 +16,6 @@ import { database as db } from '../../initializers/database' | |||
16 | import { REQUEST_VIDEO_QADU_TYPES } from '../../initializers' | 16 | import { REQUEST_VIDEO_QADU_TYPES } from '../../initializers' |
17 | import { addMethodsToModel } from '../utils' | 17 | import { addMethodsToModel } from '../utils' |
18 | import { | 18 | import { |
19 | RequestVideoQaduClass, | ||
20 | RequestVideoQaduInstance, | 19 | RequestVideoQaduInstance, |
21 | RequestVideoQaduAttributes, | 20 | RequestVideoQaduAttributes, |
22 | 21 | ||
@@ -83,20 +82,18 @@ function associate (models) { | |||
83 | }) | 82 | }) |
84 | } | 83 | } |
85 | 84 | ||
86 | countTotalRequests = function (callback: RequestVideoQaduMethods.CountTotalRequestsCallback) { | 85 | countTotalRequests = function () { |
87 | const query = {} | 86 | const query = {} |
88 | return RequestVideoQadu.count(query).asCallback(callback) | 87 | return RequestVideoQadu.count(query) |
89 | } | 88 | } |
90 | 89 | ||
91 | listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: number, callback: RequestVideoQaduMethods.ListWithLimitAndRandomCallback) { | 90 | listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: number) { |
92 | const Pod = db.Pod | 91 | const Pod = db.Pod |
93 | const tableJoin = '' | 92 | const tableJoin = '' |
94 | 93 | ||
95 | Pod.listRandomPodIdsWithRequest(limitPods, 'RequestVideoQadus', tableJoin, function (err, podIds) { | 94 | return Pod.listRandomPodIdsWithRequest(limitPods, 'RequestVideoQadus', tableJoin).then(podIds => { |
96 | if (err) return callback(err) | ||
97 | |||
98 | // We don't have friends that have requests | 95 | // We don't have friends that have requests |
99 | if (podIds.length === 0) return callback(null, []) | 96 | if (podIds.length === 0) return [] |
100 | 97 | ||
101 | const query = { | 98 | const query = { |
102 | include: [ | 99 | include: [ |
@@ -114,16 +111,14 @@ listWithLimitAndRandom = function (limitPods: number, limitRequestsPerPod: numbe | |||
114 | ] | 111 | ] |
115 | } | 112 | } |
116 | 113 | ||
117 | RequestVideoQadu.findAll(query).asCallback(function (err, requests) { | 114 | return RequestVideoQadu.findAll(query).then(requests => { |
118 | if (err) return callback(err) | ||
119 | |||
120 | const requestsGrouped = groupAndTruncateRequests(requests, limitRequestsPerPod) | 115 | const requestsGrouped = groupAndTruncateRequests(requests, limitRequestsPerPod) |
121 | return callback(err, requestsGrouped) | 116 | return requestsGrouped |
122 | }) | 117 | }) |
123 | }) | 118 | }) |
124 | } | 119 | } |
125 | 120 | ||
126 | removeByRequestIdsAndPod = function (ids: number[], podId: number, callback: RequestVideoQaduMethods.RemoveByRequestIdsAndPodCallback) { | 121 | removeByRequestIdsAndPod = function (ids: number[], podId: number) { |
127 | const query = { | 122 | const query = { |
128 | where: { | 123 | where: { |
129 | id: { | 124 | id: { |
@@ -133,12 +128,12 @@ removeByRequestIdsAndPod = function (ids: number[], podId: number, callback: Req | |||
133 | } | 128 | } |
134 | } | 129 | } |
135 | 130 | ||
136 | RequestVideoQadu.destroy(query).asCallback(callback) | 131 | return RequestVideoQadu.destroy(query) |
137 | } | 132 | } |
138 | 133 | ||
139 | removeAll = function (callback: RequestVideoQaduMethods.RemoveAllCallback) { | 134 | removeAll = function () { |
140 | // Delete all requests | 135 | // Delete all requests |
141 | RequestVideoQadu.truncate({ cascade: true }).asCallback(callback) | 136 | return RequestVideoQadu.truncate({ cascade: true }) |
142 | } | 137 | } |
143 | 138 | ||
144 | // --------------------------------------------------------------------------- | 139 | // --------------------------------------------------------------------------- |