aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-query-builder.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-query-builder.ts')
-rw-r--r--server/models/video/video-query-builder.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/server/models/video/video-query-builder.ts b/server/models/video/video-query-builder.ts
index 8f0a814de..455f9f30f 100644
--- a/server/models/video/video-query-builder.ts
+++ b/server/models/video/video-query-builder.ts
@@ -321,6 +321,10 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
321 if (options.isCount !== true) { 321 if (options.isCount !== true) {
322 322
323 if (exists(options.sort)) { 323 if (exists(options.sort)) {
324 if (options.sort === '-originallyPublishedAt' || options.sort === 'originallyPublishedAt') {
325 attributes.push('COALESCE("video"."originallyPublishedAt", "video"."publishedAt") AS "publishedAtForOrder"')
326 }
327
324 order = buildOrder(model, options.sort) 328 order = buildOrder(model, options.sort)
325 suffix += `${order} ` 329 suffix += `${order} `
326 } 330 }
@@ -365,6 +369,8 @@ function buildOrder (model: typeof Model, value: string) {
365 369
366 if (field.toLowerCase() === 'match') { // Search 370 if (field.toLowerCase() === 'match') { // Search
367 firstSort = '"similarity"' 371 firstSort = '"similarity"'
372 } else if (field === 'originallyPublishedAt') {
373 firstSort = '"publishedAtForOrder"'
368 } else if (field.includes('.')) { 374 } else if (field.includes('.')) {
369 firstSort = field 375 firstSort = field
370 } else { 376 } else {