diff --git a/lib/api-helper/goal/fetchGoalsOnCommit.ts b/lib/api-helper/goal/fetchGoalsOnCommit.ts index 5c28f93cd..27994dd77 100644 --- a/lib/api-helper/goal/fetchGoalsOnCommit.ts +++ b/lib/api-helper/goal/fetchGoalsOnCommit.ts @@ -35,6 +35,14 @@ import { import { goalKeyString } from "./sdmGoal"; import { goalCorrespondsToSdmGoal } from "./storeGoals"; +export function fetchGoalsFromPush(sdmGoal: SdmGoalEvent): SdmGoalEvent[] { + const goals = sumSdmGoalEvents((sdmGoal.push as any).goals.filter(g => g.goalSetId === sdmGoal.goalSetId)); + const push = _.cloneDeep(sdmGoal.push); + delete (push as any).goals; + goals.forEach(g => g.push = push); + return goals; +} + export async function findSdmGoalOnCommit(ctx: HandlerContext, id: RemoteRepoRef, providerId: string, goal: Goal): Promise { const sdmGoals = await fetchGoalsForCommit(ctx, id, providerId); const matches = sdmGoals.filter(g => goalCorrespondsToSdmGoal(goal, g));