Skip to content

Commit

Permalink
fix for empty assignments list
Browse files Browse the repository at this point in the history
  • Loading branch information
markdturner committed Aug 27, 2024
1 parent d0c52ee commit 06812fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/api/rse/services/rse.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function createCalendar(rse, holidays, leave, assignments, capacities, timesheet
currentAssignments = assignments.filter(assignment => {
const start = DateTime.fromISO(assignment.start),
end = DateTime.fromISO(assignment.end)
return date >= start && date <= end && assignment.rse === rse.id
return date >= start && date <= end && assignment.rse.id === rse.id
})

let dateCapacity = 0
Expand Down Expand Up @@ -78,7 +78,7 @@ function createCalendar(rse, holidays, leave, assignments, capacities, timesheet
duration: leaveDay.DURATION === 'Y' ? 7.4 : 3.7,
status: leaveDay.STATUS
} : null,
assignments: currentAssignments,
assignments: currentAssignments.map(({ rse, ...assignment }) => assignment),
timesheet: timesheetSummary
}

Expand Down Expand Up @@ -304,7 +304,7 @@ module.exports = createCoreService("api::rse.rse", ({ strapi }) => ({
year: { $eq: year }
}

let assignments = await strapi.service("api::assignment.assignment").find({filters: dateRangeFilter, populate: { project: { fields: ['name'] } } }),
let assignments = await strapi.service("api::assignment.assignment").find({filters: dateRangeFilter, populate: { rse: { fields: ['id'] }, project: { fields: ['name'] } } }),
capacities = await strapi.service("api::capacity.capacity").find({filters: dateRangeFilter}),
holidays = await fetchBankHolidays(year),
leave = await strapi.service("api::timesheet.timesheet").findLeave({filters: yearFilter}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2024-08-27T19:53:43.872Z"
"x-generation-date": "2024-08-27T20:09:29.319Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down

0 comments on commit 06812fc

Please sign in to comment.