aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-20 14:05:52 +0200
committerChocobozzz <me@florianbigard.com>2020-04-20 14:05:52 +0200
commit2fd59d7d89d1c389446ee67838c821e2622fc8ca (patch)
tree3f3e1ad83aacee895c7ff096fe54c344df8a1e06 /server/models
parent1f41ca656638bda3aec8ca1c9e99adde3c0f9fcb (diff)
downloadPeerTube-2fd59d7d89d1c389446ee67838c821e2622fc8ca.tar.gz
PeerTube-2fd59d7d89d1c389446ee67838c821e2622fc8ca.tar.zst
PeerTube-2fd59d7d89d1c389446ee67838c821e2622fc8ca.zip
Add ability to sort by originallyPublishedAt
Diffstat (limited to 'server/models')
-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 {