aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/models/video/video-query-builder.ts31
1 files changed, 18 insertions, 13 deletions
diff --git a/server/models/video/video-query-builder.ts b/server/models/video/video-query-builder.ts
index 655abf198..015bf43de 100644
--- a/server/models/video/video-query-builder.ts
+++ b/server/models/video/video-query-builder.ts
@@ -203,23 +203,28 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
203 } 203 }
204 204
205 if (options.languageOneOf) { 205 if (options.languageOneOf) {
206 replacements.languageOneOf = options.languageOneOf.filter(l => l && l !== '_unknown') 206 const languages = options.languageOneOf.filter(l => l && l !== '_unknown')
207 207 const languagesQueryParts: string[] = []
208 let languagesQuery = '("video"."language" IN (:languageOneOf) OR ' 208
209 if (languages.length !== 0) {
210 languagesQueryParts.push('("video"."language" IN (:languageOneOf)')
211 replacements.languageOneOf = languages
212
213 languagesQueryParts.push(
214 ' EXISTS (' +
215 ' SELECT 1 FROM "videoCaption" WHERE "videoCaption"."language" ' +
216 ' IN (' + createSafeIn(model, languages) + ') AND ' +
217 ' "videoCaption"."videoId" = "video"."id"' +
218 ' )' +
219 ')'
220 )
221 }
209 222
210 if (options.languageOneOf.includes('_unknown')) { 223 if (options.languageOneOf.includes('_unknown')) {
211 languagesQuery += '"video"."language" IS NULL OR ' 224 languagesQueryParts.push('"video"."language" IS NULL')
212 } 225 }
213 226
214 and.push( 227 and.push(languagesQueryParts.join(' OR '))
215 languagesQuery +
216 ' EXISTS (' +
217 ' SELECT 1 FROM "videoCaption" WHERE "videoCaption"."language" ' +
218 ' IN (' + createSafeIn(model, options.languageOneOf) + ') AND ' +
219 ' "videoCaption"."videoId" = "video"."id"' +
220 ' )' +
221 ')'
222 )
223 } 228 }
224 229
225 // We don't exclude results in this if so if we do a count we don't need to add this complex clauses 230 // We don't exclude results in this if so if we do a count we don't need to add this complex clauses