Skip to content

Commit

Permalink
Merge pull request #2285 from HHS/main
Browse files Browse the repository at this point in the history
[Prod] Optimize fetching topics on the RTR
  • Loading branch information
Jones-QuarteyDana authored Jul 22, 2024
2 parents 97e35f3 + f94562e commit 2856b2b
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/services/recipient.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ function calculatePreviousStatus(goal) {
// otherwise we check to see if there is the goal is on an activity report,
// and also check the status
if (goal.objectives.length) {
const onAr = goal.objectives.some((objective) => objective.activityReports.length);
const onAr = goal.objectives.some((objective) => objective.onApprovedAR);
const isCompletedOrInProgress = goal.objectives.some((objective) => objective.status === 'In Progress' || objective.status === 'Complete');

if (onAr && isCompletedOrInProgress) {
Expand Down Expand Up @@ -708,11 +708,12 @@ export async function getGoalsByActivityRecipient(
model: ActivityReportObjective,
as: 'activityReportObjectives',
attributes: ['id', 'objectiveId'],
separate: true,
include: [
{
model: Topic,
through: [],
as: 'topics',
attributes: ['name'],
},
],
},
Expand All @@ -733,25 +734,6 @@ export async function getGoalsByActivityRecipient(
where: {
calculatedStatus: REPORT_STATUSES.APPROVED,
},
include: [
{
model: ActivityRecipient,
as: 'activityRecipients',
attributes: ['activityReportId', 'grantId'],
required: true,
include: [
{
required: true,
model: Grant,
as: 'grant',
attributes: ['id', 'recipientId'],
where: {
recipientId,
},
},
],
},
],
},
],
},
Expand Down

0 comments on commit 2856b2b

Please sign in to comment.