3491 launch cleaning cron (#3872)

* Add command to delete incomplete workspaces

* Inject command dependencies

* Fix command

* Do not delete core.workspace

* Reorganize files

* Delete src/workspace/cron

* Fix

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
martmull
2024-02-07 18:52:48 +01:00
committed by GitHub
parent 6e3a8e3461
commit 7001ca83d1
17 changed files with 132 additions and 37 deletions

View File

@ -17,13 +17,15 @@ export class WorkspaceService extends TypeOrmQueryService<Workspace> {
super(workspaceRepository);
}
async deleteWorkspace(id: string) {
async deleteWorkspace(id: string, shouldDeleteCoreWorkspace = true) {
const workspace = await this.workspaceRepository.findOneBy({ id });
assert(workspace, 'Workspace not found');
await this.workspaceManagerService.delete(id);
await this.workspaceRepository.delete(id);
if (shouldDeleteCoreWorkspace) {
await this.workspaceRepository.delete(id);
}
return workspace;
}