MAPG-203 add cleanup for multi_rooms to db:maintain
This commit is contained in:
parent
e5fb725c69
commit
5dd2ce0d5a
@ -5,6 +5,7 @@ use MapGuesser\Database\Query\Modify;
|
|||||||
use MapGuesser\Database\Query\Select;
|
use MapGuesser\Database\Query\Select;
|
||||||
use MapGuesser\Interfaces\Database\IResultSet;
|
use MapGuesser\Interfaces\Database\IResultSet;
|
||||||
use MapGuesser\PersistentData\PersistentDataManager;
|
use MapGuesser\PersistentData\PersistentDataManager;
|
||||||
|
use MapGuesser\Repository\MultiRoomRepository;
|
||||||
use MapGuesser\Repository\UserConfirmationRepository;
|
use MapGuesser\Repository\UserConfirmationRepository;
|
||||||
use MapGuesser\Repository\UserPasswordResetterRepository;
|
use MapGuesser\Repository\UserPasswordResetterRepository;
|
||||||
use MapGuesser\Repository\UserRepository;
|
use MapGuesser\Repository\UserRepository;
|
||||||
@ -22,6 +23,8 @@ class MaintainDatabaseCommand extends Command
|
|||||||
|
|
||||||
private UserPasswordResetterRepository $userPasswordResetterRepository;
|
private UserPasswordResetterRepository $userPasswordResetterRepository;
|
||||||
|
|
||||||
|
private MultiRoomRepository $multiRoomRepository;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@ -30,6 +33,7 @@ class MaintainDatabaseCommand extends Command
|
|||||||
$this->userRepository = new UserRepository();
|
$this->userRepository = new UserRepository();
|
||||||
$this->userConfirmationRepository = new UserConfirmationRepository();
|
$this->userConfirmationRepository = new UserConfirmationRepository();
|
||||||
$this->userPasswordResetterRepository = new UserPasswordResetterRepository();
|
$this->userPasswordResetterRepository = new UserPasswordResetterRepository();
|
||||||
|
$this->multiRoomRepository = new MultiRoomRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configure(): void
|
public function configure(): void
|
||||||
@ -43,6 +47,7 @@ class MaintainDatabaseCommand extends Command
|
|||||||
try {
|
try {
|
||||||
$this->deleteInactiveExpiredUsers();
|
$this->deleteInactiveExpiredUsers();
|
||||||
$this->deleteExpiredPasswordResetters();
|
$this->deleteExpiredPasswordResetters();
|
||||||
|
$this->deleteExpiredRooms();
|
||||||
$this->deleteExpiredSessions();
|
$this->deleteExpiredSessions();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$output->writeln('<error>Maintenance failed!</error>');
|
$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
|
private function deleteExpiredSessions(): void
|
||||||
{
|
{
|
||||||
//TODO: model may be used for sessions too
|
//TODO: model may be used for sessions too
|
||||||
|
Loading…
Reference in New Issue
Block a user