Skip to content

Commit

Permalink
improve request efficiency by querying for leave username and timeshe…
Browse files Browse the repository at this point in the history
…et user ID
  • Loading branch information
markdturner committed Sep 1, 2024
1 parent 5efe2fe commit 77ea119
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/api/timesheet/services/timesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,11 @@ module.exports = ({ strapi }) => ({
}
}

let rse = await strapi.services['api::rse.rse'].findOne(rseId, rsePopulate),
holidays = await fetchBankHolidays(args[0].filters.year.$eq),
leave = await strapi.services['api::timesheet.timesheet'].leave(...args),
timesheets = await strapi.services['api::timesheet.timesheet'].find(...args)
const rse = await strapi.services['api::rse.rse'].findOne(rseId, rsePopulate)

const holidays = await fetchBankHolidays(args[0].filters.year.$eq),
leave = await strapi.services['api::timesheet.timesheet'].leave({ filters: {...args[0].filters, username: [rse.username]} }),
timesheets = await strapi.services['api::timesheet.timesheet'].find({ filters: {...args[0].filters, userIDs: [rse.clockifyID]} })

const calendar = createCalendar(rse, holidays, leave.data, rse.assignments, rse.capacities, timesheets.data, startDate, endDate)

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-09-01T21:11:54.925Z"
"x-generation-date": "2024-09-01T21:39:37.711Z"
},
"x-strapi-config": {
"path": "/documentation",
Expand Down

0 comments on commit 77ea119

Please sign in to comment.