aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r--server/models/utils.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts
index b53a52a05..4199cc443 100644
--- a/server/models/utils.ts
+++ b/server/models/utils.ts
@@ -22,6 +22,19 @@ function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderIt
22 return [ [ finalField, direction ], lastSort ] 22 return [ [ finalField, direction ], lastSort ]
23} 23}
24 24
25function getCommentSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
26 const { direction, field } = buildDirectionAndField(value)
27
28 if (field === 'totalReplies') {
29 return [
30 [ Sequelize.literal('"totalReplies"'), direction ],
31 lastSort
32 ]
33 }
34
35 return getSort(value, lastSort)
36}
37
25function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { 38function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
26 const { direction, field } = buildDirectionAndField(value) 39 const { direction, field } = buildDirectionAndField(value)
27 40
@@ -167,6 +180,7 @@ export {
167 SortType, 180 SortType,
168 buildLocalAccountIdsIn, 181 buildLocalAccountIdsIn,
169 getSort, 182 getSort,
183 getCommentSort,
170 getVideoSort, 184 getVideoSort,
171 getBlacklistSort, 185 getBlacklistSort,
172 createSimilarityAttribute, 186 createSimilarityAttribute,