diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-31 17:32:35 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-31 17:43:39 +0200 |
commit | 4b54f1360ebb5b1aeb70544981f2721e9a03f0bb (patch) | |
tree | ff54ca875a4bb22a361a7a8befceb3eb80424114 /server | |
parent | 9a629c6efbe39dfac290347670ca41b0d7100f41 (diff) | |
download | PeerTube-4b54f1360ebb5b1aeb70544981f2721e9a03f0bb.tar.gz PeerTube-4b54f1360ebb5b1aeb70544981f2721e9a03f0bb.tar.zst PeerTube-4b54f1360ebb5b1aeb70544981f2721e9a03f0bb.zip |
Fix videos overview tags section
Diffstat (limited to 'server')
-rw-r--r-- | server/models/utils.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts index edb8e1161..e0bf091ad 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts | |||
@@ -4,7 +4,11 @@ type SortType = { sortModel: any, sortValue: string } | |||
4 | 4 | ||
5 | // Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ] | 5 | // Translate for example "-name" to [ [ 'name', 'DESC' ], [ 'id', 'ASC' ] ] |
6 | function getSort (value: string, lastSort: string[] = [ 'id', 'ASC' ]) { | 6 | function getSort (value: string, lastSort: string[] = [ 'id', 'ASC' ]) { |
7 | const { direction, field } = buildDirectionAndField(value) | 7 | let { direction, field } = buildDirectionAndField(value) |
8 | |||
9 | if (field.toLowerCase() === 'match') { // Search | ||
10 | field = Sequelize.col('similarity') | ||
11 | } | ||
8 | 12 | ||
9 | return [ [ field, direction ], lastSort ] | 13 | return [ [ field, direction ], lastSort ] |
10 | } | 14 | } |
@@ -13,10 +17,9 @@ function getVideoSort (value: string, lastSort: string[] = [ 'id', 'ASC' ]) { | |||
13 | let { direction, field } = buildDirectionAndField(value) | 17 | let { direction, field } = buildDirectionAndField(value) |
14 | 18 | ||
15 | // Alias | 19 | // Alias |
16 | if (field.toLowerCase() === 'match') field = Sequelize.col('similarity') | 20 | if (field.toLowerCase() === 'match') { // Search |
17 | 21 | field = Sequelize.col('similarity') | |
18 | // Sort by aggregation | 22 | } else if (field.toLowerCase() === 'trending') { // Sort by aggregation |
19 | if (field.toLowerCase() === 'trending') { | ||
20 | return [ | 23 | return [ |
21 | [ Sequelize.fn('COALESCE', Sequelize.fn('SUM', Sequelize.col('VideoViews.views')), '0'), direction ], | 24 | [ Sequelize.fn('COALESCE', Sequelize.fn('SUM', Sequelize.col('VideoViews.views')), '0'), direction ], |
22 | 25 | ||