Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove serverless functions on soft delete #9438

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ export class ServerlessFunctionResolver {
try {
await this.checkFeatureFlag(workspaceId);

return await this.serverlessFunctionService.deleteOneServerlessFunction(
input.id,
return await this.serverlessFunctionService.deleteOneServerlessFunction({
id: input.id,
workspaceId,
);
});
} catch (error) {
serverlessFunctionGraphQLApiExceptionHandler(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,15 @@ export class ServerlessFunctionService {
});
}

async deleteOneServerlessFunction(id: string, workspaceId: string) {
async deleteOneServerlessFunction({
id,
workspaceId,
permanentlyDelete = true,
}: {
id: string;
workspaceId: string;
permanentlyDelete?: boolean;
martmull marked this conversation as resolved.
Show resolved Hide resolved
}) {
const existingServerlessFunction =
await this.serverlessFunctionRepository.findOneBy({
id,
Expand All @@ -219,16 +227,17 @@ export class ServerlessFunctionService {
);
}

await this.serverlessFunctionRepository.delete(id);
if (permanentlyDelete) {
await this.serverlessFunctionRepository.delete(id);
await this.fileStorageService.delete({
folderPath: getServerlessFolder({
serverlessFunction: existingServerlessFunction,
}),
});
}

await this.serverlessService.delete(existingServerlessFunction);

await this.fileStorageService.delete({
folderPath: getServerlessFolder({
serverlessFunction: existingServerlessFunction,
}),
});

return existingServerlessFunction;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ export class WorkflowCommonWorkspaceService {
workflowVersions.map((workflowVersion) => {
workflowVersion.steps?.map(async (step) => {
if (step.type === WorkflowActionType.CODE) {
await this.serverlessFunctionService.deleteOneServerlessFunction(
step.settings.input.serverlessFunctionId,
await this.serverlessFunctionService.deleteOneServerlessFunction({
id: step.settings.input.serverlessFunctionId,
workspaceId,
);
permanentlyDelete: false,
});
}
});
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,10 +511,10 @@ export class WorkflowVersionStepWorkspaceService {
}) {
switch (step.type) {
case WorkflowActionType.CODE: {
await this.serverlessFunctionService.deleteOneServerlessFunction(
step.settings.input.serverlessFunctionId,
await this.serverlessFunctionService.deleteOneServerlessFunction({
id: step.settings.input.serverlessFunctionId,
workspaceId,
);
});

break;
}
Expand Down
Loading