From f7f25e9428dd065a7ca5f8b1213dcf6ee88af447 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 5 Nov 2023 13:50:47 +0100 Subject: [PATCH 1/3] Added base for server statistics #420 --- bot/src/bot_graphql/abc/query_abc.py | 12 ++- bot/src/bot_graphql/graphql/server.gql | 10 +++ bot/src/bot_graphql/graphql_module.py | 2 + bot/src/bot_graphql/queries/server_query.py | 4 + .../queries/server_statistic_query.py | 77 +++++++++++++++++++ 5 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 bot/src/bot_graphql/queries/server_statistic_query.py diff --git a/bot/src/bot_graphql/abc/query_abc.py b/bot/src/bot_graphql/abc/query_abc.py index 850fb22b..b141d89b 100644 --- a/bot/src/bot_graphql/abc/query_abc.py +++ b/bot/src/bot_graphql/abc/query_abc.py @@ -38,7 +38,7 @@ class QueryABC(ObjectType): def __init__(self, name: str): ObjectType.__init__(self, name) - def add_collection(self, name: str, get_collection: Callable, filter_type: type = None): + def _get_wrapper(self, get_collection: Callable, filter_type: type = None): def wrapper(*args, **kwargs): if filter_type is not None and "filter" in kwargs: kwargs["filter"] = FilterABC.get_collection_filter(filter_type, kwargs["filter"]) @@ -67,8 +67,14 @@ class QueryABC(ObjectType): return self._resolve_collection(collection, *args, **kwargs) - self.set_field(f"{name}s", wrapper) - self.set_field(f"{name}Count", lambda *args: wrapper(*args).count()) + return wrapper + + def add_field(self, name: str, get_collection: Callable, filter_type: type = None): + self.set_field(name, self._get_wrapper(get_collection, filter_type)) + + def add_collection(self, name: str, get_collection: Callable, filter_type: type = None): + self.add_field(f"{name}s", get_collection, filter_type) + self.set_field(f"{name}Count", lambda *args: self._get_wrapper(get_collection, filter_type)(*args).count()) def _can_user_see_element(self, user: AuthUser, element: T) -> bool: @ServiceProviderABC.inject diff --git a/bot/src/bot_graphql/graphql/server.gql b/bot/src/bot_graphql/graphql/server.gql index 1e80be20..38ee1dc8 100644 --- a/bot/src/bot_graphql/graphql/server.gql +++ b/bot/src/bot_graphql/graphql/server.gql @@ -38,6 +38,8 @@ type Server implements TableWithHistoryQuery { config: ServerConfig hasFeatureFlag(flag: String): FeatureFlag + statistic(date: String): ServerStatistic + createdAt: String modifiedAt: String @@ -59,4 +61,12 @@ input ServerFilter { id: ID discordId: String name: String +} + +type ServerStatistic { + userJoinedVoiceChannelCount: Int + userJoinedVoiceChannelOntime: Int + userJoinedGameServerCount: Int + userJoinedGameServerOntime: Int + messageCount: Int } \ No newline at end of file diff --git a/bot/src/bot_graphql/graphql_module.py b/bot/src/bot_graphql/graphql_module.py index e15e0c35..95d73f7b 100644 --- a/bot/src/bot_graphql/graphql_module.py +++ b/bot/src/bot_graphql/graphql_module.py @@ -57,6 +57,7 @@ from bot_graphql.queries.level_query import LevelQuery from bot_graphql.queries.server_config_query import ServerConfigQuery from bot_graphql.queries.server_history_query import ServerHistoryQuery from bot_graphql.queries.server_query import ServerQuery +from bot_graphql.queries.server_statistic_query import ServerStatisticQuery from bot_graphql.queries.short_role_name_history_query import ShortRoleNameHistoryQuery from bot_graphql.queries.short_role_name_query import ShortRoleNameQuery from bot_graphql.queries.technician_config_history_query import ( @@ -138,6 +139,7 @@ class GraphQLModule(ModuleABC): services.add_transient(QueryABC, ShortRoleNameQuery) services.add_transient(QueryABC, UserWarningHistoryQuery) services.add_transient(QueryABC, UserWarningQuery) + services.add_transient(QueryABC, ServerStatisticQuery) services.add_transient(QueryABC, DiscordQuery) services.add_transient(QueryABC, GuildQuery) diff --git a/bot/src/bot_graphql/queries/server_query.py b/bot/src/bot_graphql/queries/server_query.py index 1398fa08..b5203724 100644 --- a/bot/src/bot_graphql/queries/server_query.py +++ b/bot/src/bot_graphql/queries/server_query.py @@ -107,6 +107,10 @@ class ServerQuery(DataQueryWithHistoryABC): "hasFeatureFlag", lambda server, *_, **kwargs: self._resolve_has_feature_flag(server, *_, **kwargs), ) + self.set_field( + "statistic", + lambda server, *_, **kwargs: server, + ) @staticmethod def resolve_id(server: Server, *_): diff --git a/bot/src/bot_graphql/queries/server_statistic_query.py b/bot/src/bot_graphql/queries/server_statistic_query.py new file mode 100644 index 00000000..7f01de89 --- /dev/null +++ b/bot/src/bot_graphql/queries/server_statistic_query.py @@ -0,0 +1,77 @@ +import datetime + +from cpl_core.configuration import ConfigurationABC + +from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC +from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC +from bot_data.abc.user_message_count_per_hour_repository_abc import UserMessageCountPerHourRepositoryABC +from bot_data.model.server_config import ServerConfig +from bot_graphql.abc.query_abc import QueryABC + + +class ServerStatisticQuery(QueryABC): + def __init__( + self, + config: ConfigurationABC, + user_joined_voice_channels: UserJoinedVoiceChannelRepositoryABC, + user_joined_game_servers: UserJoinedGameServerRepositoryABC, + user_messages: UserMessageCountPerHourRepositoryABC, + ): + QueryABC.__init__(self, "ServerStatistic") + + self._config = config + + self._user_joined_voice_channels = user_joined_voice_channels + self._user_joined_game_servers = user_joined_game_servers + self._user_messages = user_messages + + self.add_field("userJoinedVoiceChannelCount", self._resolve_voice_channel_count) + self.add_field("userJoinedVoiceChannelOntime", self._resolve_voice_channel_ontime) + self.add_field("userJoinedGameServerCount", self._resolve_game_server_count) + self.add_field("userJoinedGameServerOntime", self._resolve_game_server_ontime) + self.add_field( + "messageCount", + self._resolve_message_count, + ) + + def _resolve_voice_channel_count(self, server, *_, **kwargs): + return ( + self._user_joined_voice_channels.get_user_joined_voice_channels() + .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) + .count() + ) + + def _resolve_voice_channel_ontime(self, server, *_, **kwargs): + return ( + self._user_joined_voice_channels.get_user_joined_voice_channels() + .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) + .sum(lambda x: x.time) + ) + + def _resolve_game_server_count(self, server, *_, **kwargs): + return ( + self._user_joined_game_servers.get_user_joined_game_servers() + .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) + .count() + ) + + def _resolve_game_server_ontime(self, server, *_, **kwargs): + return ( + self._user_joined_game_servers.get_user_joined_game_servers() + .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) + .sum(lambda x: x.time) + ) + + def _resolve_message_count(self, server, *_, **kwargs): + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") + return ( + self._user_messages.get_user_message_count_per_hours() + .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) + .sum(lambda x: x.xp_count / settings.xp_per_message) + ) + + def _get_date(self, **kwargs) -> datetime.date: + if "date" not in kwargs: + return datetime.date.today() - datetime.timedelta(days=7) + + return datetime.datetime.strptime(kwargs["date"], "%d.%m.%Y").date() -- 2.45.2 From d1ecfe96038b85bce1b898e90408a3a5e8b3e266 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 5 Nov 2023 15:34:17 +0100 Subject: [PATCH 2/3] Added activity score calculation #420 --- bot/src/bot_graphql/abc/query_abc.py | 12 +- bot/src/bot_graphql/graphql/server.gql | 8 - .../bot_graphql/graphql/serverStatistic.gql | 17 ++ .../bot_graphql/model/server_statistics.py | 7 + bot/src/bot_graphql/queries/server_query.py | 6 +- .../queries/server_statistic_query.py | 150 ++++++++++++++---- 6 files changed, 144 insertions(+), 56 deletions(-) create mode 100644 bot/src/bot_graphql/graphql/serverStatistic.gql create mode 100644 bot/src/bot_graphql/model/server_statistics.py diff --git a/bot/src/bot_graphql/abc/query_abc.py b/bot/src/bot_graphql/abc/query_abc.py index b141d89b..850fb22b 100644 --- a/bot/src/bot_graphql/abc/query_abc.py +++ b/bot/src/bot_graphql/abc/query_abc.py @@ -38,7 +38,7 @@ class QueryABC(ObjectType): def __init__(self, name: str): ObjectType.__init__(self, name) - def _get_wrapper(self, get_collection: Callable, filter_type: type = None): + def add_collection(self, name: str, get_collection: Callable, filter_type: type = None): def wrapper(*args, **kwargs): if filter_type is not None and "filter" in kwargs: kwargs["filter"] = FilterABC.get_collection_filter(filter_type, kwargs["filter"]) @@ -67,14 +67,8 @@ class QueryABC(ObjectType): return self._resolve_collection(collection, *args, **kwargs) - return wrapper - - def add_field(self, name: str, get_collection: Callable, filter_type: type = None): - self.set_field(name, self._get_wrapper(get_collection, filter_type)) - - def add_collection(self, name: str, get_collection: Callable, filter_type: type = None): - self.add_field(f"{name}s", get_collection, filter_type) - self.set_field(f"{name}Count", lambda *args: self._get_wrapper(get_collection, filter_type)(*args).count()) + self.set_field(f"{name}s", wrapper) + self.set_field(f"{name}Count", lambda *args: wrapper(*args).count()) def _can_user_see_element(self, user: AuthUser, element: T) -> bool: @ServiceProviderABC.inject diff --git a/bot/src/bot_graphql/graphql/server.gql b/bot/src/bot_graphql/graphql/server.gql index 38ee1dc8..be603f3a 100644 --- a/bot/src/bot_graphql/graphql/server.gql +++ b/bot/src/bot_graphql/graphql/server.gql @@ -61,12 +61,4 @@ input ServerFilter { id: ID discordId: String name: String -} - -type ServerStatistic { - userJoinedVoiceChannelCount: Int - userJoinedVoiceChannelOntime: Int - userJoinedGameServerCount: Int - userJoinedGameServerOntime: Int - messageCount: Int } \ No newline at end of file diff --git a/bot/src/bot_graphql/graphql/serverStatistic.gql b/bot/src/bot_graphql/graphql/serverStatistic.gql new file mode 100644 index 00000000..9f3b5c9f --- /dev/null +++ b/bot/src/bot_graphql/graphql/serverStatistic.gql @@ -0,0 +1,17 @@ +type ServerStatistic { + achievementsAchieved: Int + messageCount: Int + + userCount: Int + activeUserCount: Int + + userJoinedVoiceChannelCount: Int + userJoinedVoiceChannelOntime: Int + + userJoinedGameServerCount: Int + userJoinedGameServerOntime: Int + + userWarningCount: Int + + activityScore: Int +} \ No newline at end of file diff --git a/bot/src/bot_graphql/model/server_statistics.py b/bot/src/bot_graphql/model/server_statistics.py new file mode 100644 index 00000000..45ae580e --- /dev/null +++ b/bot/src/bot_graphql/model/server_statistics.py @@ -0,0 +1,7 @@ +from bot_data.model.server import Server + + +class ServerStatistics: + def __init__(self, server: Server, kwargs: dict): + self.server = server + self.kwargs = kwargs diff --git a/bot/src/bot_graphql/queries/server_query.py b/bot/src/bot_graphql/queries/server_query.py index b5203724..14033101 100644 --- a/bot/src/bot_graphql/queries/server_query.py +++ b/bot/src/bot_graphql/queries/server_query.py @@ -26,6 +26,7 @@ from bot_graphql.filter.client_filter import ClientFilter from bot_graphql.filter.level_filter import LevelFilter from bot_graphql.filter.short_role_name_filter import ShortRoleNameFilter from bot_graphql.filter.user_filter import UserFilter +from bot_graphql.model.server_statistics import ServerStatistics class ServerQuery(DataQueryWithHistoryABC): @@ -107,10 +108,7 @@ class ServerQuery(DataQueryWithHistoryABC): "hasFeatureFlag", lambda server, *_, **kwargs: self._resolve_has_feature_flag(server, *_, **kwargs), ) - self.set_field( - "statistic", - lambda server, *_, **kwargs: server, - ) + self.set_field("statistic", lambda server, *_, **kwargs: ServerStatistics(server, kwargs)) @staticmethod def resolve_id(server: Server, *_): diff --git a/bot/src/bot_graphql/queries/server_statistic_query.py b/bot/src/bot_graphql/queries/server_statistic_query.py index 7f01de89..7fa4d9c1 100644 --- a/bot/src/bot_graphql/queries/server_statistic_query.py +++ b/bot/src/bot_graphql/queries/server_statistic_query.py @@ -2,9 +2,12 @@ import datetime from cpl_core.configuration import ConfigurationABC +from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC from bot_data.abc.user_joined_game_server_repository_abc import UserJoinedGameServerRepositoryABC from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC from bot_data.abc.user_message_count_per_hour_repository_abc import UserMessageCountPerHourRepositoryABC +from bot_data.abc.user_repository_abc import UserRepositoryABC +from bot_data.abc.user_warnings_repository_abc import UserWarningsRepositoryABC from bot_data.model.server_config import ServerConfig from bot_graphql.abc.query_abc import QueryABC @@ -13,63 +16,140 @@ class ServerStatisticQuery(QueryABC): def __init__( self, config: ConfigurationABC, + users: UserRepositoryABC, user_joined_voice_channels: UserJoinedVoiceChannelRepositoryABC, user_joined_game_servers: UserJoinedGameServerRepositoryABC, user_messages: UserMessageCountPerHourRepositoryABC, + user_warnings: UserWarningsRepositoryABC, + achievements: AchievementRepositoryABC, ): QueryABC.__init__(self, "ServerStatistic") self._config = config - + self._users = users self._user_joined_voice_channels = user_joined_voice_channels self._user_joined_game_servers = user_joined_game_servers self._user_messages = user_messages + self._user_warnings = user_warnings + self._achievements = achievements - self.add_field("userJoinedVoiceChannelCount", self._resolve_voice_channel_count) - self.add_field("userJoinedVoiceChannelOntime", self._resolve_voice_channel_ontime) - self.add_field("userJoinedGameServerCount", self._resolve_game_server_count) - self.add_field("userJoinedGameServerOntime", self._resolve_game_server_ontime) - self.add_field( + self.set_field( + "achievementsAchieved", + self._resolve_achievements, + ) + + self.set_field( "messageCount", self._resolve_message_count, ) - def _resolve_voice_channel_count(self, server, *_, **kwargs): - return ( - self._user_joined_voice_channels.get_user_joined_voice_channels() - .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) - .count() + self.set_field("userCount", lambda server, *_: self._users.get_users_by_server_id(server.server.id).count()) + self.set_field("activeUserCount", self._resolve_active_count) + + self.set_field("userJoinedVoiceChannelCount", self._resolve_voice_channel_count) + self.set_field("userJoinedVoiceChannelOntime", self._resolve_voice_channel_ontime) + + self.set_field("userJoinedGameServerCount", self._resolve_game_server_count) + self.set_field("userJoinedGameServerOntime", self._resolve_game_server_ontime) + + self.set_field("userWarningCount", self._resolve_user_warning_count) + + self.set_field("activityScore", self._resolve_activity_score) + + def _resolve_activity_score(self, server, *_): + days = (datetime.date.today() - self._get_date(**server.kwargs)).days + return int( + ( + ( + self._resolve_achievements(server, *_) + + self._resolve_message_count(server, *_) + + self._resolve_voice_channel_count(server, *_) + + self._resolve_voice_channel_ontime(server, *_) + + self._resolve_game_server_count(server, *_) + + self._resolve_game_server_ontime(server, *_) + - self._resolve_user_warning_count(server, *_) + ) + / self._resolve_active_count(server, *_) + ) + / days + * 1000 ) - def _resolve_voice_channel_ontime(self, server, *_, **kwargs): - return ( - self._user_joined_voice_channels.get_user_joined_voice_channels() - .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) - .sum(lambda x: x.time) - ) - - def _resolve_game_server_count(self, server, *_, **kwargs): - return ( - self._user_joined_game_servers.get_user_joined_game_servers() - .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) - .count() - ) - - def _resolve_game_server_ontime(self, server, *_, **kwargs): - return ( - self._user_joined_game_servers.get_user_joined_game_servers() - .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) - .sum(lambda x: x.time) - ) - - def _resolve_message_count(self, server, *_, **kwargs): - settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.discord_id}") + def _resolve_message_count(self, server, *_): + settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{server.server.discord_id}") return ( self._user_messages.get_user_message_count_per_hours() - .where(lambda x: x.user.server.id == server.id and x.created_at.date() >= self._get_date(**kwargs)) + .where( + lambda x: x.user.server.id == server.server.id + and x.created_at.date() >= self._get_date(**server.kwargs) + ) .sum(lambda x: x.xp_count / settings.xp_per_message) ) + def _resolve_active_count(self, server, *_): + return self._users.get_users_by_server_id(server.server.id).where(lambda x: not x.left_server).count() + + def _resolve_voice_channel_count(self, server, *_): + return ( + self._user_joined_voice_channels.get_user_joined_voice_channels() + .where( + lambda x: x.user.server.id == server.server.id + and x.created_at.date() >= self._get_date(**server.kwargs) + ) + .count() + ) + + def _resolve_voice_channel_ontime(self, server, *_): + return ( + self._user_joined_voice_channels.get_user_joined_voice_channels() + .where( + lambda x: x.user.server.id == server.server.id + and x.created_at.date() >= self._get_date(**server.kwargs) + ) + .sum(lambda x: x.time) + ) + + def _resolve_game_server_count(self, server, *_): + return ( + self._user_joined_game_servers.get_user_joined_game_servers() + .where( + lambda x: x.user.server.id == server.server.id + and x.created_at.date() >= self._get_date(**server.kwargs) + ) + .count() + ) + + def _resolve_game_server_ontime(self, server, *_): + return ( + self._user_joined_game_servers.get_user_joined_game_servers() + .where( + lambda x: x.user.server.id == server.server.id + and x.created_at.date() >= self._get_date(**server.kwargs) + ) + .sum(lambda x: x.time) + ) + + def _resolve_user_warning_count(self, server, *_): + return ( + self._user_warnings.get_user_warnings() + .where( + lambda x: x.user.server.id == server.server.id + and x.created_at.date() >= self._get_date(**server.kwargs) + ) + .count() + ) + + def _resolve_achievements(self, server, *_): + return ( + self._achievements.get_achievements_by_server_id(server.server.id) + .select_many(lambda x: self._achievements.get_user_got_achievements_by_achievement_id(x.id)) + .where( + lambda x: x.user.server.id == server.server.id + and x.created_at.date() >= self._get_date(**server.kwargs) + ) + .count() + ) + def _get_date(self, **kwargs) -> datetime.date: if "date" not in kwargs: return datetime.date.today() - datetime.timedelta(days=7) -- 2.45.2 From 90de90684ca44fb3f214acd4e1fed19a463bb14d Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 5 Nov 2023 15:51:25 +0100 Subject: [PATCH 3/3] Added statistics #420 --- web/src/app/models/data/server.model.ts | 14 ++++++++ web/src/app/models/graphql/queries.model.ts | 12 +++++++ .../server-statistic.component.html | 35 +++++++++++++++++++ .../server-statistic.component.scss | 0 .../server-statistic.component.spec.ts | 23 ++++++++++++ .../server-statistic.component.ts | 22 ++++++++++++ .../server-dashboard.component.html | 7 ++++ .../app/modules/view/server/server.module.ts | 2 ++ web/src/assets/i18n/de.json | 10 +++++- web/src/assets/i18n/en.json | 10 +++++- 10 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.html create mode 100644 web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.scss create mode 100644 web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.spec.ts create mode 100644 web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.ts diff --git a/web/src/app/models/data/server.model.ts b/web/src/app/models/data/server.model.ts index 024a1a6e..9c9891c3 100644 --- a/web/src/app/models/data/server.model.ts +++ b/web/src/app/models/data/server.model.ts @@ -20,6 +20,7 @@ export interface Server extends Data { autoRoles?: AutoRole[]; clientCount?: number; clients?: Client[]; + statistic?: ServerStatistic; levelCount?: number; levels?: Level[]; userCount?: number; @@ -35,3 +36,16 @@ export interface ServerFilter { discordId?: String; name?: String; } + +export interface ServerStatistic { + achievementsAchieved?: Number + messageCount?: Number + userCount?: Number + activeUserCount?: Number + userJoinedVoiceChannelCount?: Number + userJoinedVoiceChannelOntime?: Number + userJoinedGameServerCount?: Number + userJoinedGameServerOntime?: Number + userWarningCount?: Number + activityScore?: Number +} diff --git a/web/src/app/models/graphql/queries.model.ts b/web/src/app/models/graphql/queries.model.ts index d16e94c1..1f6bb6a9 100644 --- a/web/src/app/models/graphql/queries.model.ts +++ b/web/src/app/models/graphql/queries.model.ts @@ -79,6 +79,18 @@ export class Queries { receivedCommandCount movedUsersCount } + statistic { + achievementsAchieved + messageCount + userCount + activeUserCount + userJoinedVoiceChannelCount + userJoinedVoiceChannelOntime + userJoinedGameServerCount + userJoinedGameServerOntime + userWarningCount + activityScore + } } } `; diff --git a/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.html b/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.html new file mode 100644 index 00000000..5721a2e8 --- /dev/null +++ b/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.html @@ -0,0 +1,35 @@ +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
diff --git a/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.scss b/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.spec.ts b/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.spec.ts new file mode 100644 index 00000000..d88c711b --- /dev/null +++ b/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ServerStatisticComponent } from './server-statistic.component'; + +describe('ServerStatisticComponent', () => { + let component: ServerStatisticComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ServerStatisticComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ServerStatisticComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.ts b/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.ts new file mode 100644 index 00000000..369d0e9b --- /dev/null +++ b/web/src/app/modules/view/server/server-dashboard/components/server-statistic/server-statistic.component.ts @@ -0,0 +1,22 @@ +import { Component, Input } from "@angular/core"; +import { ServerStatistic } from "../../../../../../models/data/server.model"; + +@Component({ + selector: 'app-server-statistic', + templateUrl: './server-statistic.component.html', + styleUrls: ['./server-statistic.component.scss'] +}) +export class ServerStatisticComponent { + @Input() stats?: ServerStatistic = { + achievementsAchieved: 0, + messageCount: 0, + userCount: 0, + activeUserCount: 0, + userJoinedVoiceChannelCount: 0, + userJoinedVoiceChannelOntime: 0, + userJoinedGameServerCount: 0, + userJoinedGameServerOntime: 0, + userWarningCount: 0, + activityScore: 0, + }; +} 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 69fe099e..dfd2c275 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 @@ -28,6 +28,13 @@ {{'view.dashboard.server.active_members' | translate}} {{server ? server.activeUserCount : ''}} + +
+
+ +
+ +
diff --git a/web/src/app/modules/view/server/server.module.ts b/web/src/app/modules/view/server/server.module.ts index 5ac78d1c..d1810268 100644 --- a/web/src/app/modules/view/server/server.module.ts +++ b/web/src/app/modules/view/server/server.module.ts @@ -6,6 +6,7 @@ import { SharedModule } from "../../shared/shared.module"; import { ProfileComponent } from "./profile/profile.component"; import { MembersComponent } from "./members/members.component"; import { ClientComponent } from "./server-dashboard/components/client/client.component"; +import { ServerStatisticComponent } from './server-dashboard/components/server-statistic/server-statistic.component'; @NgModule({ @@ -14,6 +15,7 @@ import { ClientComponent } from "./server-dashboard/components/client/client.com ProfileComponent, MembersComponent, ClientComponent, + ServerStatisticComponent, ], imports: [ CommonModule, diff --git a/web/src/assets/i18n/de.json b/web/src/assets/i18n/de.json index aec55e53..471a0893 100644 --- a/web/src/assets/i18n/de.json +++ b/web/src/assets/i18n/de.json @@ -454,13 +454,21 @@ } }, "dashboard": { + "achievements_achieved": "Errungenschaften vergeben", + "activity_score": "Aktivitätsbewertung", "deleted_message_count": "Gelöschte Nachrichten", "header": "Server dashboard", + "message_count": "Anzahl Nachrichten", "moved_users_count": "Verschobene Benutzer", "name": "Name", "received_command_count": "Empfangene Befehle", "received_message_count": "Empfangene Nachrichten", - "sent_message_count": "Gesendete Nachrichten" + "sent_message_count": "Gesendete Nachrichten", + "user_joined_game_server_count": "Anzahl Gameserver beitritte", + "user_joined_game_server_ontime": "Gameserver Ontime", + "user_joined_voice_channel_count": "Anzahl Sprachkanal beitritte", + "user_joined_voice_channel_ontime": "Sprachkanal Ontime", + "user_warning_count": "Anzahl Verwarnungen" }, "header": "Server", "levels": { diff --git a/web/src/assets/i18n/en.json b/web/src/assets/i18n/en.json index a236d8e3..539f3570 100644 --- a/web/src/assets/i18n/en.json +++ b/web/src/assets/i18n/en.json @@ -454,13 +454,21 @@ } }, "dashboard": { + "achievements_achieved": "Achievements achieved", + "activity_score": "Activity score", "deleted_message_count": "Deleted messages", "header": "Server dashboard", + "message_count": "Message count", "moved_users_count": "Moved users", "name": "Name", "received_command_count": "Received commands", "received_message_count": "Received messages", - "sent_message_count": "Sent messages" + "sent_message_count": "Sent messages", + "user_joined_game_server_count": "Joined Gameserver count", + "user_joined_game_server_ontime": "Gameserver ontime", + "user_joined_voice_channel_count": "Joined voice channel count", + "user_joined_voice_channel_ontime": "Joined voice channel ontime", + "user_warning_count": "User warning count" }, "header": "Server", "levels": { -- 2.45.2