Added history for achievements to frontend #268_achievements
This commit is contained in:
parent
eb3715d00b
commit
f7297ddf78
@ -40,11 +40,11 @@ class AchievementsMigration(MigrationABC):
|
|||||||
CREATE TABLE IF NOT EXISTS `AchievementsHistory`
|
CREATE TABLE IF NOT EXISTS `AchievementsHistory`
|
||||||
(
|
(
|
||||||
`Id` BIGINT(20) NOT NULL,
|
`Id` BIGINT(20) NOT NULL,
|
||||||
`ServerId` BIGINT,
|
|
||||||
`Name` VARCHAR(255) NOT NULL,
|
`Name` VARCHAR(255) NOT NULL,
|
||||||
`Attribute` VARCHAR(255) NOT NULL,
|
`Attribute` VARCHAR(255) NOT NULL,
|
||||||
`Operator` VARCHAR(255) NOT NULL,
|
`Operator` VARCHAR(255) NOT NULL,
|
||||||
`Value` VARCHAR(255) NOT NULL,
|
`Value` VARCHAR(255) NOT NULL,
|
||||||
|
`ServerId` BIGINT,
|
||||||
`Deleted` BOOL DEFAULT FALSE,
|
`Deleted` BOOL DEFAULT FALSE,
|
||||||
`DateFrom` DATETIME(6) NOT NULL,
|
`DateFrom` DATETIME(6) NOT NULL,
|
||||||
`DateTo` DATETIME(6) NOT NULL
|
`DateTo` DATETIME(6) NOT NULL
|
||||||
|
@ -1,20 +1,14 @@
|
|||||||
from datetime import datetime
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from cpl_core.database import TableABC
|
|
||||||
|
|
||||||
from bot_data.abc.history_table_abc import HistoryTableABC
|
from bot_data.abc.history_table_abc import HistoryTableABC
|
||||||
from bot_data.model.server import Server
|
|
||||||
|
|
||||||
|
|
||||||
class Achievement(HistoryTableABC):
|
class AchievementHistory(HistoryTableABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
attribute: str,
|
attribute: str,
|
||||||
operator: str,
|
operator: str,
|
||||||
value: str,
|
value: str,
|
||||||
server: Optional[Server],
|
server: int,
|
||||||
deleted: bool,
|
deleted: bool,
|
||||||
date_from: str,
|
date_from: str,
|
||||||
date_to: str,
|
date_to: str,
|
||||||
@ -41,26 +35,18 @@ class Achievement(HistoryTableABC):
|
|||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@name.setter
|
@property
|
||||||
def name(self, value: str):
|
def attribute(self) -> str:
|
||||||
self._name = value
|
return self._attribute
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def operator(self) -> str:
|
def operator(self) -> str:
|
||||||
return self._operator
|
return self._operator
|
||||||
|
|
||||||
@operator.setter
|
|
||||||
def operator(self, value: str):
|
|
||||||
self._operator = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self) -> str:
|
def value(self) -> str:
|
||||||
return self._value
|
return self._value
|
||||||
|
|
||||||
@value.setter
|
|
||||||
def value(self, value: str):
|
|
||||||
self._value = value
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def server(self) -> Server:
|
def server(self) -> int:
|
||||||
return self._server
|
return self._server
|
||||||
|
@ -9,6 +9,8 @@ class UserHistory(HistoryTableABC):
|
|||||||
self,
|
self,
|
||||||
dc_id: int,
|
dc_id: int,
|
||||||
xp: int,
|
xp: int,
|
||||||
|
message_count: int,
|
||||||
|
reaction_count: int,
|
||||||
server: int,
|
server: int,
|
||||||
deleted: bool,
|
deleted: bool,
|
||||||
date_from: str,
|
date_from: str,
|
||||||
@ -20,6 +22,8 @@ class UserHistory(HistoryTableABC):
|
|||||||
self._user_id = id
|
self._user_id = id
|
||||||
self._discord_id = dc_id
|
self._discord_id = dc_id
|
||||||
self._xp = xp
|
self._xp = xp
|
||||||
|
self._message_count = message_count
|
||||||
|
self._reaction_count = reaction_count
|
||||||
self._server = server
|
self._server = server
|
||||||
|
|
||||||
self._deleted = deleted
|
self._deleted = deleted
|
||||||
@ -38,6 +42,14 @@ class UserHistory(HistoryTableABC):
|
|||||||
def xp(self) -> int:
|
def xp(self) -> int:
|
||||||
return self._xp
|
return self._xp
|
||||||
|
|
||||||
|
@property
|
||||||
|
def message_count(self) -> int:
|
||||||
|
return self._message_count
|
||||||
|
|
||||||
|
@property
|
||||||
|
def reaction_count(self) -> int:
|
||||||
|
return self._reaction_count
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def server(self) -> int:
|
def server(self) -> int:
|
||||||
return self._server
|
return self._server
|
||||||
|
@ -27,6 +27,7 @@ from bot_graphql.mutations.level_mutation import LevelMutation
|
|||||||
from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation
|
from bot_graphql.mutations.user_joined_game_server_mutation import UserJoinedGameServerMutation
|
||||||
from bot_graphql.mutations.user_mutation import UserMutation
|
from bot_graphql.mutations.user_mutation import UserMutation
|
||||||
from bot_graphql.queries.achievement_attribute_query import AchievementAttributeQuery
|
from bot_graphql.queries.achievement_attribute_query import AchievementAttributeQuery
|
||||||
|
from bot_graphql.queries.achievement_history_query import AchievementHistoryQuery
|
||||||
from bot_graphql.queries.achievement_query import AchievementQuery
|
from bot_graphql.queries.achievement_query import AchievementQuery
|
||||||
from bot_graphql.queries.auto_role_history_query import AutoRoleHistoryQuery
|
from bot_graphql.queries.auto_role_history_query import AutoRoleHistoryQuery
|
||||||
from bot_graphql.queries.auto_role_query import AutoRoleQuery
|
from bot_graphql.queries.auto_role_query import AutoRoleQuery
|
||||||
@ -69,6 +70,7 @@ class GraphQLModule(ModuleABC):
|
|||||||
# queries
|
# queries
|
||||||
services.add_transient(QueryABC, AchievementAttributeQuery)
|
services.add_transient(QueryABC, AchievementAttributeQuery)
|
||||||
services.add_transient(QueryABC, AchievementQuery)
|
services.add_transient(QueryABC, AchievementQuery)
|
||||||
|
services.add_transient(QueryABC, AchievementHistoryQuery)
|
||||||
services.add_transient(QueryABC, AutoRoleHistoryQuery)
|
services.add_transient(QueryABC, AutoRoleHistoryQuery)
|
||||||
services.add_transient(QueryABC, AutoRoleQuery)
|
services.add_transient(QueryABC, AutoRoleQuery)
|
||||||
services.add_transient(QueryABC, AutoRoleRuleHistoryQuery)
|
services.add_transient(QueryABC, AutoRoleRuleHistoryQuery)
|
||||||
|
@ -28,7 +28,7 @@ type AchievementHistory implements HistoryTableQuery {
|
|||||||
operator: String
|
operator: String
|
||||||
value: String
|
value: String
|
||||||
|
|
||||||
server: Server
|
server: ID
|
||||||
|
|
||||||
deleted: Boolean
|
deleted: Boolean
|
||||||
dateFrom: String
|
dateFrom: String
|
||||||
|
13
kdb-bot/src/bot_graphql/queries/achievement_history_query.py
Normal file
13
kdb-bot/src/bot_graphql/queries/achievement_history_query.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from bot_graphql.abc.history_query_abc import HistoryQueryABC
|
||||||
|
|
||||||
|
|
||||||
|
class AchievementHistoryQuery(HistoryQueryABC):
|
||||||
|
def __init__(self):
|
||||||
|
HistoryQueryABC.__init__(self, "Achievement")
|
||||||
|
|
||||||
|
self.set_field("id", lambda x, *_: x.id)
|
||||||
|
self.set_field("name", lambda x, *_: x.name)
|
||||||
|
self.set_field("attribute", lambda x, *_: x.attribute)
|
||||||
|
self.set_field("operator", lambda x, *_: x.operator)
|
||||||
|
self.set_field("value", lambda x, *_: x.value)
|
||||||
|
self.set_field("server", lambda x, *_: x.server)
|
@ -1,6 +1,6 @@
|
|||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
|
|
||||||
from bot_data.model.user_history import UserHistory
|
from bot_data.model.achievement_history import AchievementHistory
|
||||||
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
from bot_graphql.abc.data_query_with_history_abc import DataQueryWithHistoryABC
|
||||||
|
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ class AchievementQuery(DataQueryWithHistoryABC):
|
|||||||
self,
|
self,
|
||||||
db: DatabaseContextABC,
|
db: DatabaseContextABC,
|
||||||
):
|
):
|
||||||
DataQueryWithHistoryABC.__init__(self, "Achievement", "AchievementsHistory", UserHistory, db)
|
DataQueryWithHistoryABC.__init__(self, "Achievement", "AchievementsHistory", AchievementHistory, db)
|
||||||
|
|
||||||
self.set_field("id", lambda x, *_: x.id)
|
self.set_field("id", lambda x, *_: x.id)
|
||||||
self.set_field("name", lambda x, *_: x.name)
|
self.set_field("name", lambda x, *_: x.name)
|
||||||
|
@ -147,7 +147,10 @@
|
|||||||
"permissions": "Berechtigung",
|
"permissions": "Berechtigung",
|
||||||
"roleId": "Rolle",
|
"roleId": "Rolle",
|
||||||
"server": "Server",
|
"server": "Server",
|
||||||
"xp": "XP"
|
"xp": "XP",
|
||||||
|
"attribute": "Attribut",
|
||||||
|
"operator": "Operator",
|
||||||
|
"value": "Wert"
|
||||||
},
|
},
|
||||||
"id": "Id",
|
"id": "Id",
|
||||||
"joined_at": "Beigetreten am",
|
"joined_at": "Beigetreten am",
|
||||||
|
@ -147,7 +147,10 @@
|
|||||||
"permissions": "Permissions",
|
"permissions": "Permissions",
|
||||||
"roleId": "Role",
|
"roleId": "Role",
|
||||||
"server": "Server",
|
"server": "Server",
|
||||||
"xp": "XP"
|
"xp": "XP",
|
||||||
|
"attribute": "Attribute",
|
||||||
|
"operator": "Operator",
|
||||||
|
"value": "Value"
|
||||||
},
|
},
|
||||||
"id": "Id",
|
"id": "Id",
|
||||||
"joined_at": "Joined at",
|
"joined_at": "Joined at",
|
||||||
|
Loading…
Reference in New Issue
Block a user