From 7c64cf6354b2be4ba9e2b5df752e24decbd45c79 Mon Sep 17 00:00:00 2001 From: Rob Ellison Date: Tue, 21 Nov 2023 19:42:56 +0000 Subject: [PATCH] fix: resourcing --- components/resourcing/ResourceTable.js | 20 ++++++++++++++++++-- lib/github/index.js | 2 ++ lib/loaders/index.js | 19 +++++++++++++++---- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/components/resourcing/ResourceTable.js b/components/resourcing/ResourceTable.js index e1c60af8..bc6b6c80 100644 --- a/components/resourcing/ResourceTable.js +++ b/components/resourcing/ResourceTable.js @@ -316,9 +316,25 @@ function Row({ data, displayedMonths, setPopupContent, setShowPopup, placeholder data.jobs.some(item => item.month === month) ? determineColor(data.jobs.find(item => item.month === month)) : 'transparent' - } label={data.jobs.find(item => item.month === month).jobs.reduce((sum, job) => sum + parseInt(job.days, 10), 0)} /> + } + label={data.jobs.find(item => item.month === month).days_allocated} /> } - + {data.jobs.some(item => item.month === month) && data.jobs.find(item => item.month === month).days_forecast > 0 && + + 0) ? '50px' : '100px', + }} + + // color={ + // data.jobs.some(item => item.month === month) ? + // determineColor(data.jobs.find(item => item.month === month)) + // : 'transparent' + // } + label={data.jobs.find(item => item.month === month).days_forecast} /> +} ))} diff --git a/lib/github/index.js b/lib/github/index.js index f84c19fc..4936bd7e 100644 --- a/lib/github/index.js +++ b/lib/github/index.js @@ -115,6 +115,8 @@ export async function getFileContent(owner, repo, branch, path, sha = null) { } } catch (error) { console.info('[Github][Read][Error]:', cacheKey, 'error: ', error) + console.info('[Github][Read][Error]:', cacheKey, 'cachedContent: ', cachedContent) + return cachedContent; } // console.info('[Github][Cache][HIT]:',cacheKey ) diff --git a/lib/loaders/index.js b/lib/loaders/index.js index e31d52e8..460b1a6d 100644 --- a/lib/loaders/index.js +++ b/lib/loaders/index.js @@ -219,7 +219,15 @@ export function expandResourceData(data, userData) { item.jobs.forEach(job => { const month = job.month; - const days = parseInt(job.days, 10) || 0; // Ensure days is a number, default to 0 if NaN + let days_allocated = 0; + let days_forecast = 0; + + if (job.exp_coge === 'Y') { // job has been forcast to Coge + days_allocated = parseInt(job.days, 10) || 0; // Ensure days is a number, default to 0 if NaN + } else { // this is not forcast yet + days_forecast = parseInt(job.days, 10) || 0; // Ensure days is a number, default to 0 if NaN + } + // Initialize days_hypo and days_working as null let hypoDd = null; @@ -240,6 +248,7 @@ export function expandResourceData(data, userData) { month: month, jobs: [], days_allocated: 0, + days_forecast: 0, days_hypo: hypoDd, // Initialize with hypoDd if it's a number days_working: workDd // Initialize with workDd if it's a number }; @@ -257,7 +266,8 @@ export function expandResourceData(data, userData) { jobsByMonth[month].jobs.push(job); // Sum the days - jobsByMonth[month].days_allocated += days; + jobsByMonth[month].days_allocated += days_allocated; + jobsByMonth[month].days_forecast += days_forecast; }); // After all jobs have been processed for this item @@ -270,8 +280,9 @@ export function expandResourceData(data, userData) { }); // Filter out months where days_allocated is 0 - const filteredJobsByMonth = Object.values(jobsByMonth).filter(monthData => monthData.days_allocated > 0); - + const filteredJobsByMonth = Object.values(jobsByMonth).filter(monthData => + monthData.days_allocated > 0 || monthData.days_forecast > 0); + // Replace the jobs array with the filtered grouped data item.jobs = filteredJobsByMonth; return item;