diff --git a/bot/src/bot_graphql/graphql/server.gql b/bot/src/bot_graphql/graphql/server.gql index 2dda4cef..1e80be20 100644 --- a/bot/src/bot_graphql/graphql/server.gql +++ b/bot/src/bot_graphql/graphql/server.gql @@ -26,6 +26,7 @@ type Server implements TableWithHistoryQuery { gameServers: [GameServer] userCount: Int + activeUserCount: Int users(filter: UserFilter, page: Page, sort: Sort): [User] achievementCount: Int diff --git a/bot/src/bot_graphql/queries/server_query.py b/bot/src/bot_graphql/queries/server_query.py index edd647cd..1398fa08 100644 --- a/bot/src/bot_graphql/queries/server_query.py +++ b/bot/src/bot_graphql/queries/server_query.py @@ -76,6 +76,10 @@ class ServerQuery(DataQueryWithHistoryABC): lambda server, *_: self._levels.get_levels_by_server_id(server.id), LevelFilter, ) + self.set_field( + "activeUserCount", + lambda server, *_: self._users.get_users_by_server_id(server.id).where(lambda x: not x.left_server).count(), + ) self.add_collection( "user", lambda server, *_: self._users.get_users_by_server_id(server.id), diff --git a/web/src/app/models/data/server.model.ts b/web/src/app/models/data/server.model.ts index 483a6e46..024a1a6e 100644 --- a/web/src/app/models/data/server.model.ts +++ b/web/src/app/models/data/server.model.ts @@ -23,6 +23,7 @@ export interface Server extends Data { levelCount?: number; levels?: Level[]; userCount?: number; + activeUserCount?: number; users?: User[]; config?: ServerConfig; hasFeatureFlag?: FeatureFlag; diff --git a/web/src/app/models/graphql/queries.model.ts b/web/src/app/models/graphql/queries.model.ts index f2a4f32a..d16e94c1 100644 --- a/web/src/app/models/graphql/queries.model.ts +++ b/web/src/app/models/graphql/queries.model.ts @@ -68,6 +68,7 @@ export class Queries { name iconURL userCount + activeUserCount clients { id discordId diff --git a/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html index 743d265f..7d02f084 100644 --- a/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html +++ b/web/src/app/modules/view/dashboard/components/dashboard/dashboard.component.html @@ -40,6 +40,7 @@ {{server.userCount}} {{'view.dashboard.server.member_count' | translate}} + {{'view.dashboard.server.active_members' | translate}} {{server ? server.activeUserCount : ''}} diff --git a/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html index f8263f8d..69fe099e 100644 --- a/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html +++ b/web/src/app/modules/view/server/server-dashboard/server-dashboard.component.html @@ -23,9 +23,9 @@
- - {{server ? server.userCount : ''}} + {{server ? server.userCount : ''}} {{'view.dashboard.server.member_count' | translate}} + {{'view.dashboard.server.active_members' | translate}} {{server ? server.activeUserCount : ''}}