feature/MAPG-203-initial-multiplayer-implementation #8

Merged
bence merged 17 commits from feature/MAPG-203-initial-multiplayer-implementation into develop 2021-03-20 20:46:37 +01:00
Showing only changes of commit 5dd2ce0d5a - Show all commits

View File

@ -5,6 +5,7 @@ use MapGuesser\Database\Query\Modify;
use MapGuesser\Database\Query\Select;
use MapGuesser\Interfaces\Database\IResultSet;
use MapGuesser\PersistentData\PersistentDataManager;
use MapGuesser\Repository\MultiRoomRepository;
use MapGuesser\Repository\UserConfirmationRepository;
use MapGuesser\Repository\UserPasswordResetterRepository;
use MapGuesser\Repository\UserRepository;
@ -22,6 +23,8 @@ class MaintainDatabaseCommand extends Command
private UserPasswordResetterRepository $userPasswordResetterRepository;
private MultiRoomRepository $multiRoomRepository;
public function __construct()
{
parent::__construct();
@ -30,6 +33,7 @@ class MaintainDatabaseCommand extends Command
$this->userRepository = new UserRepository();
$this->userConfirmationRepository = new UserConfirmationRepository();
$this->userPasswordResetterRepository = new UserPasswordResetterRepository();
$this->multiRoomRepository = new MultiRoomRepository();
}
public function configure(): void
@ -43,6 +47,7 @@ class MaintainDatabaseCommand extends Command
try {
$this->deleteInactiveExpiredUsers();
$this->deleteExpiredPasswordResetters();
$this->deleteExpiredRooms();
$this->deleteExpiredSessions();
} catch (\Exception $e) {
$output->writeln('<error>Maintenance failed!</error>');
@ -89,6 +94,13 @@ class MaintainDatabaseCommand extends Command
}
}
private function deleteExpiredRooms(): void
{
foreach ($this->multiRoomRepository->getAllExpired() as $multiRoom) {
$this->pdm->deleteFromDb($multiRoom);
}
}
private function deleteExpiredSessions(): void
{
//TODO: model may be used for sessions too