Added achievements to data integrity service #268_achievements
This commit is contained in:
parent
926323252a
commit
bb23b60cec
@ -24,6 +24,7 @@ from bot_data.model.user_joined_server import UserJoinedServer
|
|||||||
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
||||||
from bot_data.service.seeder_service import SeederService
|
from bot_data.service.seeder_service import SeederService
|
||||||
from bot_data.service.user_repository_service import ServerRepositoryABC
|
from bot_data.service.user_repository_service import ServerRepositoryABC
|
||||||
|
from modules.achievements.achievement_service import AchievementService
|
||||||
from modules.base.configuration.base_server_settings import BaseServerSettings
|
from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||||
|
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ class DataIntegrityService:
|
|||||||
user_joins: UserJoinedServerRepositoryABC,
|
user_joins: UserJoinedServerRepositoryABC,
|
||||||
user_joins_vc: UserJoinedVoiceChannelRepositoryABC,
|
user_joins_vc: UserJoinedVoiceChannelRepositoryABC,
|
||||||
user_joined_gs: UserJoinedGameServerRepositoryABC,
|
user_joined_gs: UserJoinedGameServerRepositoryABC,
|
||||||
|
achievement_service: AchievementService,
|
||||||
dtp: DateTimeOffsetPipe,
|
dtp: DateTimeOffsetPipe,
|
||||||
):
|
):
|
||||||
self._config = config
|
self._config = config
|
||||||
@ -57,6 +59,7 @@ class DataIntegrityService:
|
|||||||
self._user_joins = user_joins
|
self._user_joins = user_joins
|
||||||
self._user_joins_vc = user_joins_vc
|
self._user_joins_vc = user_joins_vc
|
||||||
self._user_joined_gs = user_joined_gs
|
self._user_joined_gs = user_joined_gs
|
||||||
|
self._achievements = achievement_service
|
||||||
self._dtp = dtp
|
self._dtp = dtp
|
||||||
|
|
||||||
self._is_for_shutdown = False
|
self._is_for_shutdown = False
|
||||||
@ -360,6 +363,25 @@ class DataIntegrityService:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(__name__, f"Cannot get UserJoinedGameServer", e)
|
self._logger.error(__name__, f"Cannot get UserJoinedGameServer", e)
|
||||||
|
|
||||||
|
def _check_for_user_achievements(self):
|
||||||
|
self._logger.debug(__name__, f"Start checking UserGotAchievement table")
|
||||||
|
|
||||||
|
for guild in self._bot.guilds:
|
||||||
|
server = self._servers.find_server_by_discord_id(guild.id)
|
||||||
|
if server is None:
|
||||||
|
self._logger.fatal(__name__, f"Server not found in database: {guild.id}")
|
||||||
|
|
||||||
|
for member in guild.members:
|
||||||
|
if member.bot:
|
||||||
|
self._logger.trace(__name__, f"User {member.id} is ignored, because its a bot")
|
||||||
|
continue
|
||||||
|
|
||||||
|
user = self._users.find_user_by_discord_id_and_server_id(member.id, server.id)
|
||||||
|
if user is None:
|
||||||
|
self._logger.fatal(__name__, f"User not found in database: {member.id}")
|
||||||
|
|
||||||
|
self._achievements.validate_achievements_for_user(user)
|
||||||
|
|
||||||
def check_data_integrity(self, is_for_shutdown=False):
|
def check_data_integrity(self, is_for_shutdown=False):
|
||||||
if is_for_shutdown != self._is_for_shutdown:
|
if is_for_shutdown != self._is_for_shutdown:
|
||||||
self._is_for_shutdown = is_for_shutdown
|
self._is_for_shutdown = is_for_shutdown
|
||||||
@ -371,3 +393,4 @@ class DataIntegrityService:
|
|||||||
self._check_user_joins()
|
self._check_user_joins()
|
||||||
self._check_user_joins_vc()
|
self._check_user_joins_vc()
|
||||||
self._check_user_joined_gs()
|
self._check_user_joined_gs()
|
||||||
|
self._check_for_user_achievements()
|
||||||
|
Loading…
Reference in New Issue
Block a user