Add comment filtering by reply count

This commit is contained in:
Rigel Kent 2019-12-27 17:02:34 +01:00
parent 6f79be110d
commit c1125bcadc
No known key found for this signature in database
GPG key ID: 5E53E96A494E452F
8 changed files with 47 additions and 7 deletions

View file

@ -22,6 +22,19 @@ function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderIt
return [ [ finalField, direction ], lastSort ]
}
function getCommentSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
const { direction, field } = buildDirectionAndField(value)
if (field === 'totalReplies') {
return [
[ Sequelize.literal('"totalReplies"'), direction ],
lastSort
]
}
return getSort(value, lastSort)
}
function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
const { direction, field } = buildDirectionAndField(value)
@ -167,6 +180,7 @@ export {
SortType,
buildLocalAccountIdsIn,
getSort,
getCommentSort,
getVideoSort,
getBlacklistSort,
createSimilarityAttribute,