From cb5ce4cb13095dbea6e5f05b96eaa42ffccf0716 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Nov 2019 11:16:43 +0100 Subject: [PATCH] Add more filters to admin follows table --- .../followers-list/followers-list.component.html | 6 ++---- .../following-list/following-list.component.html | 6 ++---- server/initializers/constants.ts | 4 ++-- server/models/activitypub/actor-follow.ts | 6 +++--- server/models/utils.ts | 14 ++++++++++++++ 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.html b/client/src/app/+admin/follows/followers-list/followers-list.component.html index 7d5711926..6b5f3b450 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.html +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.html @@ -13,10 +13,9 @@ - ID Follower handle - State - Score + State + Score Created @@ -24,7 +23,6 @@ - {{ follow.id }} {{ follow.follower.name + '@' + follow.follower.host }} Accepted diff --git a/client/src/app/+admin/follows/following-list/following-list.component.html b/client/src/app/+admin/follows/following-list/following-list.component.html index 5bc8fbc2d..5a252eda9 100644 --- a/client/src/app/+admin/follows/following-list/following-list.component.html +++ b/client/src/app/+admin/follows/following-list/following-list.component.html @@ -15,18 +15,16 @@ - ID Host - State + State Created - Redundancy allowed + Redundancy allowed - {{ follow.id }} {{ follow.following.host }} Accepted diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index eaad84bee..a1538f3ca 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -49,8 +49,8 @@ const SORTABLE_COLUMNS = { VIDEO_COMMENT_THREADS: [ 'createdAt' ], VIDEO_RATES: [ 'createdAt' ], BLACKLISTS: [ 'id', 'name', 'duration', 'views', 'likes', 'dislikes', 'uuid', 'createdAt' ], - FOLLOWERS: [ 'createdAt' ], - FOLLOWING: [ 'createdAt' ], + FOLLOWERS: [ 'createdAt', 'state', 'score' ], + FOLLOWING: [ 'createdAt', 'redundancyAllowed', 'state' ], VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'views', 'likes', 'trending' ], diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index c3c4d61ab..c65b975d2 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts @@ -23,7 +23,7 @@ import { logger } from '../../helpers/logger' import { getServerActor } from '../../helpers/utils' import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' import { ServerModel } from '../server/server' -import { createSafeIn, getSort } from '../utils' +import { createSafeIn, getSort, getFollowsSort } from '../utils' import { ActorModel, unusedActorAttributesForAPI } from './actor' import { VideoChannelModel } from '../video/video-channel' import { AccountModel } from '../account/account' @@ -324,7 +324,7 @@ export class ActorFollowModel extends Model { distinct: true, offset: start, limit: count, - order: getSort(sort), + order: getFollowsSort(sort), where: followWhere, include: [ { @@ -391,7 +391,7 @@ export class ActorFollowModel extends Model { distinct: true, offset: start, limit: count, - order: getSort(sort), + order: getFollowsSort(sort), where: followWhere, include: [ { 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 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() @@ -163,6 +176,7 @@ export { buildWhereIdOrUUID, isOutdated, parseAggregateResult, + getFollowsSort, createSafeIn } -- 2.41.0