refactor(deployments): unify old deployment clearing logic for applications and composes

- Renamed and consolidated the functions for clearing old deployments to a single method, `clearOldDeployments`, which now accepts an ID and type (application or compose).
- Updated the logic to filter deployments based on status and type, improving code maintainability and reducing redundancy.
This commit is contained in:
Mauricio Siu
2026-02-16 22:15:39 -06:00
parent 95a944c4e5
commit a511f4db40
3 changed files with 14 additions and 102 deletions

View File

@@ -2,7 +2,7 @@ import {
addDomainToCompose,
addNewService,
checkServiceAccess,
clearOldDeploymentsByComposeId,
clearOldDeployments,
cloneCompose,
createCommand,
createCompose,
@@ -278,7 +278,7 @@ export const composeRouter = createTRPCRouter({
"You are not authorized to clear deployments for this compose",
});
}
const result = await clearOldDeploymentsByComposeId(input.composeId);
const result = await clearOldDeployments(input.composeId, "compose");
return {
success: true,
message: `${result.deletedCount} old deployments cleared successfully`,