diff options
author | Chocobozzz <me@florianbigard.com> | 2019-11-29 11:16:43 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-11-29 11:16:43 +0100 |
commit | cb5ce4cb13095dbea6e5f05b96eaa42ffccf0716 (patch) | |
tree | fbfcb2b23b78a7dc464df22c166bee34b5b8bcb0 /server/models/utils.ts | |
parent | 97ecddae104f4013d261f0e9645e8b319ff0f1a6 (diff) | |
download | PeerTube-cb5ce4cb13095dbea6e5f05b96eaa42ffccf0716.tar.gz PeerTube-cb5ce4cb13095dbea6e5f05b96eaa42ffccf0716.tar.zst PeerTube-cb5ce4cb13095dbea6e5f05b96eaa42ffccf0716.zip |
Add more filters to admin follows table
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r-- | server/models/utils.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts index ccdbcd1cf..b53a52a05 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts | |||
@@ -58,6 +58,19 @@ function getBlacklistSort (model: any, value: string, lastSort: OrderItem = [ 'i | |||
58 | return [ firstSort, lastSort ] | 58 | return [ firstSort, lastSort ] |
59 | } | 59 | } |
60 | 60 | ||
61 | function getFollowsSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { | ||
62 | const { direction, field } = buildDirectionAndField(value) | ||
63 | |||
64 | if (field === 'redundancyAllowed') { | ||
65 | return [ | ||
66 | [ 'ActorFollowing', 'Server', 'redundancyAllowed', direction ], | ||
67 | lastSort | ||
68 | ] | ||
69 | } | ||
70 | |||
71 | return getSort(value, lastSort) | ||
72 | } | ||
73 | |||
61 | function isOutdated (model: { createdAt: Date, updatedAt: Date }, refreshInterval: number) { | 74 | function isOutdated (model: { createdAt: Date, updatedAt: Date }, refreshInterval: number) { |
62 | const now = Date.now() | 75 | const now = Date.now() |
63 | const createdAtTime = model.createdAt.getTime() | 76 | const createdAtTime = model.createdAt.getTime() |
@@ -163,6 +176,7 @@ export { | |||
163 | buildWhereIdOrUUID, | 176 | buildWhereIdOrUUID, |
164 | isOutdated, | 177 | isOutdated, |
165 | parseAggregateResult, | 178 | parseAggregateResult, |
179 | getFollowsSort, | ||
166 | createSafeIn | 180 | createSafeIn |
167 | } | 181 | } |
168 | 182 | ||