mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Add ability to sort by originallyPublishedAt
This commit is contained in:
parent
1f41ca6566
commit
2fd59d7d89
3 changed files with 50 additions and 9 deletions
|
@ -321,6 +321,10 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
|
|||
if (options.isCount !== true) {
|
||||
|
||||
if (exists(options.sort)) {
|
||||
if (options.sort === '-originallyPublishedAt' || options.sort === 'originallyPublishedAt') {
|
||||
attributes.push('COALESCE("video"."originallyPublishedAt", "video"."publishedAt") AS "publishedAtForOrder"')
|
||||
}
|
||||
|
||||
order = buildOrder(model, options.sort)
|
||||
suffix += `${order} `
|
||||
}
|
||||
|
@ -365,6 +369,8 @@ function buildOrder (model: typeof Model, value: string) {
|
|||
|
||||
if (field.toLowerCase() === 'match') { // Search
|
||||
firstSort = '"similarity"'
|
||||
} else if (field === 'originallyPublishedAt') {
|
||||
firstSort = '"publishedAtForOrder"'
|
||||
} else if (field.includes('.')) {
|
||||
firstSort = field
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue