Skip to content

Commit

Permalink
feat: add cbc er to gcpe report
Browse files Browse the repository at this point in the history
  • Loading branch information
rafasdc committed Oct 7, 2024
1 parent b41d424 commit 7c7f84d
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 7 deletions.
34 changes: 27 additions & 7 deletions app/backend/lib/reporting/gcpe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,33 @@ import {
getHouseholdCount,
getTotalProjectBudget,
handleProjectType,
handleCbcEconomicRegions,
} from './util';

const getCbcDataQuery = `
query getCbcData {
allCbcData {
edges {
node {
projectNumber
jsonData
query getCbcData {
allCbcData {
edges {
node {
projectNumber
jsonData
cbcByCbcId {
communitiesSourceDataByCbcProjectCommunityCbcIdAndCommunitiesSourceDataId {
edges {
cbcProjectCommunitiesByCommunitiesSourceDataId {
nodes {
communitiesSourceDataByCommunitiesSourceDataId {
economicRegion
}
}
}
}
}
}
}
}
}
}
`;

const getCcbcQuery = `
Expand Down Expand Up @@ -210,7 +224,13 @@ const generateExcelData = async (
// project title
{ value: node?.jsonData?.projectTitle },
// economic region
{ value: 'TBD' },
{
value: handleCbcEconomicRegions(
node?.cbcByCbcId
?.communitiesSourceDataByCbcProjectCommunityCbcIdAndCommunitiesSourceDataId
?.edges
),
},
// federal funding source
{ value: node?.jsonData?.federalFundingSource },
// status
Expand Down
28 changes: 28 additions & 0 deletions app/backend/lib/reporting/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,31 @@ export const compareAndMarkArrays = (array1: any, array2: any) => {
});
});
};

export const handleCbcEconomicRegions = (
economicRegionEdges: any[]
): string => {
const regions = [];
economicRegionEdges?.forEach((edge) => {
if (
edge?.cbcProjectCommunitiesByCommunitiesSourceDataId?.nodes?.[0]
?.communitiesSourceDataByCommunitiesSourceDataId?.economicRegion
) {
if (
!regions.includes(
edge?.cbcProjectCommunitiesByCommunitiesSourceDataId?.nodes?.[0]
?.communitiesSourceDataByCommunitiesSourceDataId?.economicRegion
)
) {
regions.push(
edge?.cbcProjectCommunitiesByCommunitiesSourceDataId?.nodes?.[0]
?.communitiesSourceDataByCommunitiesSourceDataId?.economicRegion
);
}
}
});
if (regions.length === 0) {
return null;
}
return regions.join(', ');
};
51 changes: 51 additions & 0 deletions app/tests/backend/lib/reporting/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21599,6 +21599,57 @@ export const cbcDataQueryResult = {
nditConditionalApprovalLetterSent: true,
bindingAgreementSignedNditRecipient: true,
},
cbcByCbcId: {
communitiesSourceDataByCbcProjectCommunityCbcIdAndCommunitiesSourceDataId:
{
edges: [
{
cbcProjectCommunitiesByCommunitiesSourceDataId: {
nodes: [
{
communitiesSourceDataByCommunitiesSourceDataId: {
economicRegion: 'Northeast / Nord-est',
},
},
],
},
},
{
cbcProjectCommunitiesByCommunitiesSourceDataId: {
nodes: [
{
communitiesSourceDataByCommunitiesSourceDataId: {
economicRegion: 'Northeast / Nord-est',
},
},
],
},
},
{
cbcProjectCommunitiesByCommunitiesSourceDataId: {
nodes: [
{
communitiesSourceDataByCommunitiesSourceDataId: {
economicRegion: 'Thompson--Okanagan',
},
},
],
},
},
{
cbcProjectCommunitiesByCommunitiesSourceDataId: {
nodes: [
{
communitiesSourceDataByCommunitiesSourceDataId: {
economicRegion: 'Northeast / Nord-est',
},
},
],
},
},
],
},
},
},
},
],
Expand Down

0 comments on commit 7c7f84d

Please sign in to comment.