import { Model, Sequelize } from 'sequelize-typescript'
-import * as validator from 'validator'
+import validator from 'validator'
import { Col } from 'sequelize/types/lib/utils'
-import { col, literal, OrderItem } from 'sequelize'
+import { literal, OrderItem } from 'sequelize'
type SortType = { sortModel: string, sortValue: string }
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)
return [ firstSort, lastSort ]
}
+function getFollowsSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] {
+ const { direction, field } = buildDirectionAndField(value)
+
+ if (field === 'redundancyAllowed') {
+ return [
+ [ 'ActorFollowing', 'Server', 'redundancyAllowed', direction ],
+ lastSort
+ ]
+ }
+
+ return getSort(value, lastSort)
+}
+
function isOutdated (model: { createdAt: Date, updatedAt: Date }, refreshInterval: number) {
const now = Date.now()
const createdAtTime = model.createdAt.getTime()
SortType,
buildLocalAccountIdsIn,
getSort,
+ getCommentSort,
getVideoSort,
getBlacklistSort,
createSimilarityAttribute,
buildWhereIdOrUUID,
isOutdated,
parseAggregateResult,
+ getFollowsSort,
createSafeIn
}