diff --git a/CHANGELOG.md b/CHANGELOG.md index 80b4cda4e..e473e38a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/backend/lib/reporting/gcpe.ts b/app/backend/lib/reporting/gcpe.ts index 061499134..dc1c48534 100644 --- a/app/backend/lib/reporting/gcpe.ts +++ b/app/backend/lib/reporting/gcpe.ts @@ -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 = ` @@ -122,9 +137,17 @@ const getCcbcQuery = ` analystStatus intakeNumber organizationName + rowId } } } + allApplicationErs { + nodes { + applicationId + ccbcNumber + er + } + } } `; @@ -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 @@ -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 diff --git a/app/backend/lib/reporting/util.ts b/app/backend/lib/reporting/util.ts index 8bd6d1084..e1cc4dd12 100644 --- a/app/backend/lib/reporting/util.ts +++ b/app/backend/lib/reporting/util.ts @@ -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(', '); +}; diff --git a/app/tests/backend/lib/reporting/testData.ts b/app/tests/backend/lib/reporting/testData.ts index b456139b3..e30c062ef 100644 --- a/app/tests/backend/lib/reporting/testData.ts +++ b/app/tests/backend/lib/reporting/testData.ts @@ -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', + }, + }, + ], + }, + }, + ], + }, + }, }, }, ], @@ -21613,6 +21664,7 @@ export const ccbcDataQueryResult = { { node: { id: 'WyJhcHBsaWNhdGlvbnMiLDIxXQ==', + rowId: 1, formData: { jsonData: { review: { @@ -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', + }, + ], + }, }, }; diff --git a/db/sqitch.plan b/db/sqitch.plan index 87a444f66..54e50edcc 100644 --- a/db/sqitch.plan +++ b/db/sqitch.plan @@ -707,3 +707,4 @@ clean_pre_cut_over_cbc_history 2024-10-15T23:26:47Z ,,, # R @1.197.4 2024-10-17T17:46:23Z CCBC Service Account # release v1.197.4 @1.197.5 2024-10-17T18:43:02Z CCBC Service Account # release v1.197.5 @1.198.0 2024-10-18T16:12:02Z CCBC Service Account # release v1.198.0 +@1.199.0 2024-10-18T16:28:05Z CCBC Service Account # release v1.199.0 diff --git a/package.json b/package.json index c1ee8a203..6febbfbb0 100644 --- a/package.json +++ b/package.json @@ -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 ",