refactor: Project deletion in worker

This commit is contained in:
Binyamin Yawitz
2024-06-27 18:27:04 -04:00
parent 5e14cdef11
commit 4e4fcc06fd
3 changed files with 15 additions and 27 deletions
+4 -24
View File
@@ -95,9 +95,6 @@ class Deletes extends Action
case DELETE_TYPE_USERS:
$this->deleteUser($getProjectDB, $document, $project);
break;
case DELETE_TYPE_TEAMS:
$this->deleteTeam($dbForConsole, $getProjectDB, $document, $project);
break;
case DELETE_TYPE_BUCKETS:
$this->deleteBucket($getProjectDB, $deviceForFiles, $document, $project);
break;
@@ -112,6 +109,9 @@ class Deletes extends Action
break;
}
break;
case DELETE_TYPE_TEAM_PROJECTS:
$this->deleteProjectsByTeam($dbForConsole, $getProjectDB, $document);
break;
case DELETE_TYPE_EXECUTIONS:
$this->deleteExecutionLogs($project, $getProjectDB, $executionRetention);
break;
@@ -416,7 +416,7 @@ class Deletes extends Action
* @return void
* @throws Exception
*/
private function deleteMemberships(callable $getProjectDB, Document $document, Document $project): void
public function deleteMemberships(callable $getProjectDB, Document $document, Document $project): void
{
$dbForProject = $getProjectDB($project);
$teamInternalId = $document->getInternalId();
@@ -1162,24 +1162,4 @@ class Deletes extends Action
);
}
}
/**
* @param Database $dbForConsole
* @param callable $getProjectDB
* @param Document $team
* @param Document $project
* @throws Authorization
* @throws Conflict
* @throws DatabaseException
* @throws Exception
* @throws Restricted
* @throws Structure
*/
public function deleteTeam(Database $dbForConsole, callable $getProjectDB, Document $team, Document $project): void
{
$this->deleteMemberships($getProjectDB, $team, $project);
if ($project->getId() === 'console') {
$this->deleteProjectsByTeam($dbForConsole, $getProjectDB, $team);
}
}
}