Skip to content

Commit

Permalink
Track goal sets that were already canceled in this command
Browse files Browse the repository at this point in the history
[changelog:changed]
  • Loading branch information
cdupuis committed Jun 2, 2021
1 parent ede22b4 commit dddfaba
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/pack/goal-state/cancelGoals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,20 @@ export function cancelGoalSetsCommand(sdm: SoftwareDeliveryMachine): CommandHand
if (!!ci.parameters.goalSetId) {
await cancelGoalSet(ci.parameters.goalSetId, ci.context, id);
} else {
const canceledGoalSets = [];
let pgs = await pendingGoalSets(ci.context, sdm.configuration.name);
let count = 0;
while (pgs.length > 0) {
for (const pg of pgs) {
canceledGoalSets.push(pgs);
await cancelGoalSet(pg.goalSetId, ci.context);
count++;
}
pgs = await pendingGoalSets(ci.context, sdm.configuration.name);
pgs = (await pendingGoalSets(ci.context, sdm.configuration.name))
.filter(gs => !canceledGoalSets.includes(gs.goalSetId));
}
await ci.context.messageClient.respond(
slackSuccessMessage(
"Cancel Goal Sets",
`Successfully canceled ${count} pending goal ${count > 1 ? "sets" : "set"}`));
`Successfully canceled ${canceledGoalSets.length} pending goal ${canceledGoalSets.length > 1 ? "sets" : "set"}`));
}
},
};
Expand Down

0 comments on commit dddfaba

Please sign in to comment.