improve build cancel disabled logic to prevent redundant cancels

This commit is contained in:
mbecker20
2024-06-02 17:50:33 -07:00
parent 99641b2e39
commit 40e1b1ff88
3 changed files with 52 additions and 34 deletions

View File

@@ -125,3 +125,35 @@ export const logToHtml = (log: string) => {
});
return convert.toHtml(sanitized);
};
export const getUpdateQuery = (
target: Types.ResourceTarget,
deployments: Types.DeploymentListItem[] | undefined
) => {
const build_id =
target.type === "Deployment"
? deployments?.find((d) => d.id === target.id)?.info.build_id
: undefined;
if (build_id) {
return {
$or: [
{
"target.type": target.type,
"target.id": target.id,
},
{
"target.type": "Build",
"target.id": build_id,
operation: {
$in: [Types.Operation.RunBuild, Types.Operation.CancelBuild],
},
},
],
};
} else {
return {
"target.type": target.type,
"target.id": target.id,
};
}
};