Skip to content

Commit

Permalink
Merge pull request #2425 from HHS/mb/TTAHUB-3528/fix-for-duplicating-…
Browse files Browse the repository at this point in the history
…objective

[TTAHUB-3528] Do not deduplicate on objectiveCreatedHere
  • Loading branch information
thewatermethod authored Oct 25, 2024
2 parents a4b74e2 + a85a2b7 commit 3119f1a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/goalServices/reduceGoals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,23 @@ export function reduceObjectivesForActivityReport(
? objective.activityReportObjectives[0].supportType : null;

const objectiveCreatedHere = objective.activityReportObjectives
&& objective.activityReportObjectives[0]
&& objective.activityReportObjectives[0].objectiveCreatedHere
? objective.activityReportObjectives[0].objectiveCreatedHere : null;
&& objective.activityReportObjectives.some((aro) => aro.objectiveCreatedHere) ? true : null;

// objectives represent the accumulator in the find below
// objective is the objective as it is returned from the API
const exists = objectives.find((o) => (
o.title.trim() === objective.title.trim()
&& o.status === objectiveStatus
&& o.objectiveCreatedHere === objectiveCreatedHere
));

if (exists) {
const { id } = objective;
exists.ids = [...exists.ids, id];

if (objectiveCreatedHere && !exists.objectiveCreatedHere) {
exists.objectiveCreatedHere = true;
}

// we can dedupe these using lodash
exists.resources = reduceRelationThroughActivityReportObjectives(
objective,
Expand Down

0 comments on commit 3119f1a

Please sign in to comment.