Skip to content

Commit

Permalink
fix: resourcing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Ellison committed Nov 21, 2023
1 parent aff8c39 commit 7c64cf6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
20 changes: 18 additions & 2 deletions components/resourcing/ResourceTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&

<Chip
sx={{
color: 'grey',
width: '100%'
// minWidth: (placeholder?.monthlyDetails?.[month]?.days_allocated > 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} />
}
</Stack>
</TableCell>
))}
Expand Down
2 changes: 2 additions & 0 deletions lib/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
19 changes: 15 additions & 4 deletions lib/loaders/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
};
Expand All @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 7c64cf6

Please sign in to comment.