Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add economic regions to gcpe report #3578

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [1.199.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.198.0...v1.199.0) (2024-10-18)

### Features

- add cbc er to gcpe report ([1d7672b](https://github.com/bcgov/CONN-CCBC-portal/commit/1d7672bc57d83b51175dbe3a603fc5051214583c))
- add ccbc er to gcpe report ([93513b8](https://github.com/bcgov/CONN-CCBC-portal/commit/93513b85a2e58bd86a48f73f0cb6cdb4f4dbce99))

# [1.198.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.197.5...v1.198.0) (2024-10-18)

### Features
Expand Down
50 changes: 42 additions & 8 deletions app/backend/lib/reporting/gcpe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,34 @@ import {
getHouseholdCount,
getTotalProjectBudget,
handleProjectType,
handleCbcEconomicRegions,
handleCcbcEconomicRegions,
} 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 @@ -122,9 +137,17 @@ const getCcbcQuery = `
analystStatus
intakeNumber
organizationName
rowId
}
}
}
allApplicationErs {
nodes {
applicationId
ccbcNumber
er
}
}
}
`;

Expand Down Expand Up @@ -210,7 +233,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 Expand Up @@ -334,7 +363,12 @@ const generateExcelData = async (
// project title
{ value: node?.formData?.jsonData?.projectInformation?.projectTitle },
// economic region
{ value: 'TBD' },
{
value: handleCcbcEconomicRegions(
node?.rowId,
ccbcData?.data?.allApplicationErs?.nodes
),
},
// federal funding source
{ value: 'ISED-UBF Core' },
// status
Expand Down
42 changes: 42 additions & 0 deletions app/backend/lib/reporting/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,45 @@ export const compareAndMarkArrays = (array1: any, array2: any) => {
});
});
};

export const handleCcbcEconomicRegions = (
applicationId: Number,
economicRegionNodes: {
applicationId: Number;
er: string;
ccbcNumber: string;
}[]
): string | null => {
const match = economicRegionNodes?.find(
(node) => node.applicationId === applicationId
);
return match?.er || null;
};

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(', ');
};
61 changes: 61 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 All @@ -21613,6 +21664,7 @@ export const ccbcDataQueryResult = {
{
node: {
id: 'WyJhcHBsaWNhdGlvbnMiLDIxXQ==',
rowId: 1,
formData: {
jsonData: {
review: {
Expand Down Expand Up @@ -22069,6 +22121,15 @@ export const ccbcDataQueryResult = {
},
],
},
allApplicationErs: {
nodes: [
{
applicationId: 1,
ccbcNumber: 'CCBC-010001',
er: 'Vancouver Island and Coast / Île de Vancouver et la côte',
},
],
},
},
};

Expand Down
1 change: 1 addition & 0 deletions db/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -707,3 +707,4 @@ clean_pre_cut_over_cbc_history 2024-10-15T23:26:47Z ,,, <ryohani89@NH504670> # R
@1.197.4 2024-10-17T17:46:23Z CCBC Service Account <ccbc@button.is> # release v1.197.4
@1.197.5 2024-10-17T18:43:02Z CCBC Service Account <ccbc@button.is> # release v1.197.5
@1.198.0 2024-10-18T16:12:02Z CCBC Service Account <ccbc@button.is> # release v1.198.0
@1.199.0 2024-10-18T16:28:05Z CCBC Service Account <ccbc@button.is> # release v1.199.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CONN-CCBC-portal",
"version": "1.198.0",
"version": "1.199.0",
"main": "index.js",
"repository": "https://github.com/bcgov/CONN-CCBC-portal.git",
"author": "Romer, Meherzad CITZ:EX <Meherzad.Romer@gov.bc.ca>",
Expand Down
Loading