aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/pod/pod.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/pod/pod.ts')
-rw-r--r--server/models/pod/pod.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/models/pod/pod.ts b/server/models/pod/pod.ts
index 6619726af..6b33336b8 100644
--- a/server/models/pod/pod.ts
+++ b/server/models/pod/pod.ts
@@ -130,7 +130,7 @@ incrementScores = function (ids: number[], value: number) {
130 const options = { 130 const options = {
131 where: { 131 where: {
132 id: { 132 id: {
133 $in: ids 133 [Sequelize.Op.in]: ids
134 } 134 }
135 }, 135 },
136 // In this case score is a literal and not an integer so we do not validate it 136 // In this case score is a literal and not an integer so we do not validate it
@@ -178,6 +178,7 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta
178 let start = Math.floor(Math.random() * count) - limit 178 let start = Math.floor(Math.random() * count) - limit
179 if (start < 0) start = 0 179 if (start < 0) start = 0
180 180
181 const subQuery = `(SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins})`
181 const query = { 182 const query = {
182 attributes: [ 'id' ], 183 attributes: [ 'id' ],
183 order: [ 184 order: [
@@ -187,7 +188,7 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta
187 limit: limit, 188 limit: limit,
188 where: { 189 where: {
189 id: { 190 id: {
190 $in: Sequelize.literal(`(SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins})`) 191 [Sequelize.Op.in]: Sequelize.literal(subQuery)
191 } 192 }
192 } 193 }
193 } 194 }
@@ -201,7 +202,9 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta
201listBadPods = function () { 202listBadPods = function () {
202 const query = { 203 const query = {
203 where: { 204 where: {
204 score: { $lte: 0 } 205 score: {
206 [Sequelize.Op.lte]: 0
207 }
205 } 208 }
206 } 209 }
207 210