aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/utils.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2019-12-27 17:02:34 +0100
committerRigel Kent <sendmemail@rigelk.eu>2019-12-27 17:02:44 +0100
commitc1125bcadc1fa129856e56dc62f4c472cffa736a (patch)
treee6873bf7a306bfe809809f099d2d465dae3407b0 /server/models/utils.ts
parent6f79be110d31f4f751b989fe36b9de0d0f259fe0 (diff)
downloadPeerTube-c1125bcadc1fa129856e56dc62f4c472cffa736a.tar.gz
PeerTube-c1125bcadc1fa129856e56dc62f4c472cffa736a.tar.zst
PeerTube-c1125bcadc1fa129856e56dc62f4c472cffa736a.zip
Add comment filtering by reply count
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,