Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix sort builder

Chocobozzz275f26defc82
diff --git a/server/core/models/video/sql/video/videos-id-list-query-builder.ts b/server/core/models/video/sql/video/videos-id-list-query-builder.ts
index 65d6442997..a7750fd5df 100644
--- a/server/core/models/video/sql/video/videos-id-list-query-builder.ts
+++ b/server/core/models/video/sql/video/videos-id-list-query-builder.ts
@@ -1018,11 +1018,20 @@ export class VideosIdListQueryBuilder extends AbstractRunQuery {
private setSort (column: string, direction: 'ASC' | 'DESC') {
if (column.match(/^[a-zA-Z."]+$/) === null) throw new Error('Invalid sort column ' + column)
- if (column === 'random') return 'ORDER BY RANDOM()'
- if (column === 'total') return `ORDER BY "total" ${direction}`
+ if (column === 'random') {
+ this.sort = 'ORDER BY RANDOM()'
+ return
+ }
+
+ if (column === 'total') {
+ this.sort = `ORDER BY "total" ${direction}`
+ return
+ }
- if ([ 'trending', 'hot', 'best' ].includes(column)) { // Sort by aggregation
- return `ORDER BY "score" ${direction}`
+ // Sort by aggregation
+ if ([ 'trending', 'hot', 'best' ].includes(column)) {
+ this.sort = `ORDER BY "score" ${direction}`
+ return
}
let firstSort: string