From 77ea119356a54eeac2d55a7434d71b17dd4ba550 Mon Sep 17 00:00:00 2001 From: Mark Turner Date: Sun, 1 Sep 2024 22:40:49 +0100 Subject: [PATCH] improve request efficiency by querying for leave username and timesheet user ID --- src/api/timesheet/services/timesheet.js | 9 +++++---- .../documentation/1.0.0/full_documentation.json | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/api/timesheet/services/timesheet.js b/src/api/timesheet/services/timesheet.js index 8656cf3..e1d3824 100644 --- a/src/api/timesheet/services/timesheet.js +++ b/src/api/timesheet/services/timesheet.js @@ -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) diff --git a/src/extensions/documentation/documentation/1.0.0/full_documentation.json b/src/extensions/documentation/documentation/1.0.0/full_documentation.json index f3e877c..84664dc 100644 --- a/src/extensions/documentation/documentation/1.0.0/full_documentation.json +++ b/src/extensions/documentation/documentation/1.0.0/full_documentation.json @@ -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",