Skip to content

Commit

Permalink
Admin Console & microplanning Patch fixes on project factory (#1276)
Browse files Browse the repository at this point in the history
* Enabled commands for debug remotely for  project factory pod (#1249)

* HLM service request, updated DataTypeEnum (#872)

* Service request changelog 1.5 (#875)

* Added changelog and upgraded the versions for household, individual and service request

* Update core-services/service-request/CHANGELOG.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update health-services/individual/CHANGELOG.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* HLM fixed merge issues

* HLM fixed merge issues

* HCMPRE-413: updated the changelog as per code review comments

* Update health-services/project/CHANGELOG.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: kavi_elrey@1993 <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* HCMPRE-424: fixed hrms call from pgr-service

* HCMPRE-424: updated as per code review comments

* Create branch-name-validator (#960)

* Create branch-name-validator

* Update branch-name-validator

* Update .github/workflows/branch-name-validator

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update .github/workflows/branch-name-validator

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update branch-name-validator

* Rename branch-name-validator to branch-name-validator.yml

* Added census-service in build-config (#990)

* [HCMPRE-658] Refractor resource-estimation-service to resource-generator (#910)

Co-authored-by: Priyanka-eGov <[email protected]>

* Update package.json

* Update tsconfig.json

* Added configs and env dependencies

* dockerfile update

* Update tsconfig.json

* Update tsconfig.json

* refactored

* HCM Admin Console v0.3 Release code changes (#1082)

* kafka fix for large messages

* Update genericUtils.ts

* Update campaignValidators.ts

* Fixed the mdms search path keys

* fix of migration script

* fix on repeated key

* Update campaignApis.ts

* Update campaignApis.ts

* Update campaignUtils.ts

* Update campaignUtils.ts

* Update campaignUtils.ts

* Fix project target mapping

* refactored migration files fro project-factory (#867)

* refactored migration files fro project-factory

* updated logic for unique username generation

* updated format and id name  for user name

* removed hash logic for username generation

* added indexing on columns

* updated idgen seq format for user name in index.ts

* Update health-services/project-factory/src/server/api/campaignApis.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* updated logic for regenerate if campaign type differs (#876)

* id generation throw error update

* Enhance generate template for user and facility in update  ongoing campaign flow (#885)

* commit for update-generate-template

* updated campaign  flow generate template enhancement

* just if else changes

* some reformatting

* update index.ts

* added additional valiadtion for parent campaign

* updated logic for validating  parent campaign

* refcatored as per change requests

* update index.ts

* updated logic for same campaignnumber when paren is present

* updated the campaign name logic along with handling isfailed status too (#888)

* updating campaign name same as parent name and number too

* updated target template for updating ongoing campaign (#893)

* Microplan bulk user creation (#890)

* Feat : initialised bulk user creation for microplan

* Enhanced user bulk upload for microplan

* Fixed configs

* Merge fix with console

* Feat : added columns in user sheet

* Added userroles sheet for bulk user template in microplan

* Added source microplan while resource creation

* changed logic for isSourceMicroplan

* Update campaignApis.ts

* Update campaignValidators.ts

* changes for campaign update flow

* Update campaignUtils.ts

* Integrated required error messages

* added numeric check in  microplan phone number

* Implemented no data validation

* added logic for creating projects , project facility and project staff on newly added boundaries (#917)

* updated target template for updating ongoing campaign

* update flow campaign mapping

* updated flow campaign mapping

* added logic for project, project facility and project staff  creation on newly added boundaries

* removed one useless func

* removed await from a func

* removed console.logs

* added some minor enhancemnets

* added one edge case scenario

* changed request limit to 1 mb

* Feat : added locksheet filter for user microplan creation

* updated logic for regenerate if campaign type differs (#876)

* Enhancement for microplan user creation (#940)

* some modifications for edge cases (#930)

* added commit for testing  update campaign flow

* some chenages related to type boundary in data create api

* /* MODIFIED FOR LTS UPGRADE */

* Microplan user enhancement

* Some changes regarding microplan user and boundary

* added some null checks

* /* Temporay fix for project creation of LLIN since the structure of delivery rules is getting changed */

* Revert "/* MODIFIED FOR LTS UPGRADE */"

This reverts commit 52ed772.

* added code to add lat long in the project-factory apis

* Changed code based on comments

* removed default campaignid

* added code to add lat long in the project-factory apis (#951)

* added code to add lat long in the project-factory apis

* Changed code based on comments

* removed default campaignid

* Fixed code to manage create

* fixed the build

* added for field protection on sheet data

* Facility microplan validation (#975)

* Microplan facility validation

* Enhancement in microplan validations

* Microplan sheet lock

* Enhanced for multiple sheetErrors in additionalDetails

* Update campaignApis.ts

* fixes for filestore and unfreezing boundary code mandatory columns (#984)

* Update CODEOWNERS

* Update campaignValidators.ts (#987)

* some  correction of error after changes from microplan code merge (#988)

* some  correction of error after changes from microplan code merge

* added question mark

* added localization fix (#993)

Co-authored-by: ansh-egov <[email protected]>

* Update campaignApis.ts (#994)

* Added some fixes for the project transformation

* Update projectTypeUtils.ts

* Update campaignUtils.ts

* Removed date Update projectTypeUtils.ts #1006

* HCEMPRE-809-Boundary-geometry-codes (#1011)

* added localization fix

* added logic for boundaryGeometryManagement

* fixed some things

* fixed campaign search

* update  project facility and staff mappings of exisitng facilities and users  (#998)

* some  correction of error after changes from microplan code merge

* added logic for updating mapping of existing facilitie and users

* resolved comments by jagan on the pr for delinking and linking project resources

* fetchProjectsWithBoundaryCodeAndName fucntion update

* Update campaignValidators.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* added code to add lat long in the project-factory apis (#1019)

* Project staff mapping correction from uuid to userserviceuuid (#1022)

* some  correction of error after changes from microplan code merge

* corrected for mapping of project staff

* added changes for project-resource mapping (#1028)

* added changes for project-resource mapping

* changed the variable name to boundaryProjectMappingForProjectResourceCreation from newBoundaryProjectMapping

* renamed the entity

---------

Co-authored-by: Jagankumar <[email protected]>

* Added logic to retry in project campaign create (#1031)

* not needed to update every resource in update flow (#1036)

* not needed to update every resource in update flow

* added changes for if boundaries present in update  flow all resources are mandate

* Some checks enhancement (#1042)

* Update genericApis.ts (#1043)

* Update campaignValidators.ts (#1046)

* consolidate resources array in update campaign flow (#1051)

* consolidate resources array in update campaign flow

* spelling correct

* Search criteria  object corrected (#1052)

* consolidate resources array in update campaign flow

* data search criteria  id has to be an array of strings

* spelling

* some more corrections regarding search criteria body

* Boundaries consolidate after creating child campaign (#1056)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* Boundaries correction (#1058)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* changes in extracing boundaries from campaign object

* Missing resources in chid campaign to be added from parent camaig  logic refactored  (#1059)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* refactored logic for adding missing resources from parent campaign

* Correction datatocreate column from status to userservice uuids (#1061)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* changed data to create column from user sheet

* Hide Boundary and Target Old Columns (#1062)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* hide boundary code  old and target old

* Corrected target update flow (#1065)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* corrected target mapping in update flow

* Total count of Campaigns if only is active true (#1066)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* count will be only of active campaigns

* HCMPRE-1212:: migrated to point only to MMDS v2 api

* Update index.ts

* User/facility inactive (#1070)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* added logic for making exiting user facility inactive

---------

Co-authored-by: Jagankumar <[email protected]>

* Refactor facility mappings  (#1072)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* refactored facility mappings

* Created enity for boundary

* updated the boundary relationship function

* Update index.ts

* fixed some localization issue (#1075)

* fixed some localization issue

* fixed

* Target update while campaign update flow (#1078)

* consolidate resources array in update campaign flow

* boundaries consolidate after creating  child campaign

* logic for updating targets

* some refactor for adding logs and index.ts

* updated the boundary localisation name

---------

Co-authored-by: Jagankumar <[email protected]>

* fixed some localization issue (#1079)

* fixed some localization issue

* fixed

* fixed a issue

* reverted failed campaign is active true from false (#1080)

* reverted failed campaign is active true from false

* took constants from index

* refactor

* Merge branch 'project-factory-kafka-fix' into console

* Changed hierarchyFectch to v2 (#1077)

* Changed hierarchyFectch to v2

* Changed messages

* Merge branch 'project-factory-kafka-fix' into hierarchyFetchV2

---------

Co-authored-by: Jagankumar <[email protected]>

* calll generate when create completes for type boundary management

* auto generate resource if there is no previous generated history

* Fixed crashloop issue (#1084)

* Fixed crashloop issue

* Update dataManageService.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* changed the master from hierarchyConfig to HierarchySchema (#1086)

* getting boundaries split on logic change (#1088)

* fixed some localization issue (#1090)

* fixed some localization issue

* fixed

* fixed a issue

* integrated microplan with console

* fixxed index

* fixed crashloop (#1091)

* added validation for boundary bulk upload (#1092)

Co-authored-by: Jagankumar <[email protected]>

* refcatored diffferent tab separation (#1093)

* added timeout (#1095)

* Microplan integration :: set start date to tommorow (#1096)

* set start date to tommorow

* updated end date

* Enhance PlanFacility object (#1099)

* validation for update template in create flow (#1100)

* removed await (#1103)

* some correction (#1104)

* logic for updating targets only when present in resources array in update flow (#1105)

* updated (#1106)

* updated

* added fix for the redis error in logs

---------

Co-authored-by: Jagankumar <[email protected]>

* added error responder (#1107)

* refactored download api (#1108)

* Cache issue fix(#1109)

* refactored download api

* refactor

---------

Co-authored-by: Jagankumar <[email protected]>

* made disable of cache always during boundary generate (#1110)

Co-authored-by: Jagankumar <[email protected]>

* Redis cache key deleted (#1113)

* removed await

* delete cache from boundary relationship search

* updated redis delete func

* Revert "removed await"

This reverts commit a5acb54.

* Update redisUtils.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* updated redis delete func (#1114)

* removed cache from boundary relation create (#1115)

* corrected params of auto generate after download api (#1116)

* refactored consolidate (#1119)

* fix on the fetch from microplan Update campaignUtils.ts (#1120)

* Update microplanUtils.ts (#1123)

* addded localization function (#1125)

* Update SearchCriteria.ts

* made createandtransfrom localization as await to upsert all localization in boundary management create flow (#1127)

* added logs in handledropdownthings (#1128)

* Fixed district missing issue (#1129)

* Facility Village List For microplan and dropdown fix (#1130)

* Facility Village List For microplan and dropdown fix

* Optional chaining

* Reverted recievedDropdown Changes

* removed localization caceh in boundary generate flow for hierarchy module (#1133)

* planFacility create Fix (#1132)

* fixed the localisation cache on multiple data creates in boundary

* Revert "fixed the localisation cache on multiple data creates in boundary"

This reverts commit 94eb970.

* Facility fix generation for microplan (#1134)

* planFacility create Fix

* Fixed Facility Generation for microplan

* added the count info of the localisation upsert (#1144)

Co-authored-by: Jagankumar <[email protected]>

* Microplan integrated with console for facility , user & target (#1151)

* set start date to tommorow

* updated end date

* added code for target sheet

* fixed

* added mdms call

* microplan integration changes added for target ,facility & user

* undo changes

* Update microplanIntergration.ts

* saving all the progress on the integration

* project facility mapping done

* Update microplanIntergration.ts

* Update microplanIntergration.ts

* Update microplanIntergration.ts

* target & facility integration completed statically

* completed facility & target file created based on microplan

* added static for user

* Added user related changes

* added the user integartion

* added target and facility in resources array of campaign from microplan

* added user in resources array in campaign object

* Update microplanIntergration.ts

* revert the others

* Update index.ts

* Cleaned up code

---------

Co-authored-by: ansh-egov <[email protected]>
Co-authored-by: Jagankumar <[email protected]>
Co-authored-by: nitish-egov <[email protected]>

* added missing default tenantid (#1152)

* Boundary locale fix (#1153)

* planFacility create Fix

* Fixed boundary validation for different locales

---------

Co-authored-by: Jagankumar <[email protected]>

* removed duplicate key (#1154)

* Logs for reordering added (#1161)

* added missing default tenantid

* added logs for reordering before project creation

* Update index.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* Readme for microplans (#1160)

* Readme for microplans

* Fixed boolean type

* Optimized isMicroplanRequest

* Optimizing roles for microplan (#1164)

* Improved  some performance with huge campaign object (#1165)

* Trying optimised code by chatgpt

* added 4mb limit

* Update app.ts

* Updted the comments

* Changes for pollutils and reorder

* Update pollUtils.ts

---------

Co-authored-by: Jagankumar <[email protected]>
Co-authored-by: ashish-egov <[email protected]>

* Added fixes for error during processing (#1172)

* added missing default tenantid

* added try catch

* Update index.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* fixed the hard codings in the code (#1170)

* fixed the hard codings in the code

* fixed

* Added filter check for the fetch from microplan if it has already some resources

* fixed hardcoding in target flow (#1175)

* fixed hardcoding in target flow

* fixed

* fixed

* Update campaignApis.ts (#1177)

* Update campaignApis.ts

* Update campaignApis.ts

* Update campaignApis.ts

* Update genericUtils.ts (#1178)

* changed the campaig key to activity (#1180)

* added missing default tenantid

* Update campaignUtils.ts

* Update index.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* handled failed generations in downlaod api (#1185)

* Change for roles name change (#1187)

* added search before update in fetch all datas (#1190)

* added seacrh before update in fetch all datas

* Change for roles name change (#1187)

---------

Co-authored-by: ashish-egov <[email protected]>
Co-authored-by: Jagankumar <[email protected]>

* formatted and made promise all to do a promise all to make calls parallely

* filtered the plan facility response to have only facility which has only service boundarires

* added hierarchy filteration from mdms (#1188)

* added hierarchy filteration from mdms

* did some hardcoding

* fixed fetching of headers

* added some logs

* added extra loggers for fetch from microplan activities (#1193)

* added extra loggers for fetch from microplan activities

* Update microplanIntergration.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* added retry in localization upsert (#1194)

* Adding the additonal loggers to know more informs on microplan integration

* Update health-services/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update health-services/project-factory/src/server/validators/campaignValidators.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update health-services/project-factory/src/server/controllers/campaignManage/campaignManage.controller.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fixed integration (#1197)

* Global handler (#1199)

* Change for roles name change

* Global exception handler integrated

* String logger

* Update app.ts

* added heap memory log & created a env variable for incomingRequestPay…   …loadLimit (#1201)

* added heap memory log & created a env variable for incomingRequestPayloadLimit

* Update index.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* Set memory limit and added log off avaiable, max limits (#1202)

* added logs to check current value

* Update app.ts

* Update Dockerfile

* Update Dockerfile

* Update app.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* Handle for google sheet formulas (#1207)

* Update microplanValidators.ts (#1213)

* Update microplanValidators.ts

* Update microplanValidators.ts

* Update microplanValidators.ts

* Localised roles (#1217)

* added change log for admin console version 0.3 (#1224)

* Pvar validation (#1225)

* product variant validation added

* Optimized validations

* Refactored

* Logger error fix

* Refactor

* Refactor

* refactored project reosurce mapping logic (#1204)

* refactored project reosurce mapping logic

* added new function ot search project after campaign creation time

* added reference id  params in project search

* added logic for adding resources only for newly created projects

* refactored and code clean up for project resource mapppings in update and create flow

* refactor getProjectMappingBody func

* some condition check

* correction

* removed project departments

* microplan save topic changes (#1231)

* Update microplanUtils.ts

* Update index.ts

* Update campaignApis.ts (#1232)

* Update campaignApis.ts

* Update campaignApis.ts

* Update campaignApis.ts

* Update campaignValidators.ts

* Revert boundaryProject Mapping

* Cleaned up data configs (#1234)

* Update index.ts

* Update campaignUtils.ts

* Update health-services/project-factory/src/server/utils/onGoingCampaignUpdateUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update app.ts

* Update health-services/project-factory/src/server/utils/microplanUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* added changes for performance testing (#1236)

* added changes for performance testing

* microplan save topic changes (#1231)

* Update microplanUtils.ts

* Update index.ts

* Update campaignApis.ts (#1232)

* Update campaignApis.ts

* Update campaignApis.ts

* Update campaignApis.ts

* Update campaignValidators.ts

* Revert boundaryProject Mapping

* Cleaned up data configs (#1234)

* Update index.ts

* Update campaignUtils.ts

* try catch handling

* Update health-services/project-factory/src/server/service/dataManageService.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: ashish-egov <[email protected]>
Co-authored-by: ansh-egov <[email protected]>
Co-authored-by: Jagankumar <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update health-services/project-factory/src/server/utils/onGoingCampaignUpdateUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update app.ts

* Update health-services/project-factory/src/server/utils/microplanUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update campaignValidators.ts (#1244)

* Update campaignValidators.ts

* Update campaignValidators.ts

* add

* added new config values

* Other configs (#1250)

* add

* added new config values

* Update request.ts

---------

Co-authored-by: Jagankumar <[email protected]>

* Updating debug function for error handeling (#1243)

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update health-services/project-factory/src/server/service/dataManageService.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update dataManageService.ts

* Applied code rabbit changes

* refactored sheet consolidate logic (#1254)

* refactored sheet consolidate logic

* Applied code rabbit changes

---------

Co-authored-by: Jagankumar <[email protected]>

* refactor sheet consolidate for target (#1255)

* Update package.json

* Update health-services/project-factory/src/server/utils/onGoingCampaignUpdateUtils.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* removed other ui workflows

* Update publishProjectFactory.yml

* Update publishProjectFactory.yml

* Update publishProjectFactory.yml

* Update publishProjectFactory.yml

* Update publishProjectFactory.yml

* Update publishProjectFactory.yml

* consolidate sheet handle logic change (#1256)

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: ashish-egov <[email protected]>
Co-authored-by: ashish-egov <[email protected]>
Co-authored-by: nitish-egov <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: nitish-egov <[email protected]>
Co-authored-by: ansh-egov <[email protected]>
Co-authored-by: ansh-egov <[email protected]>
Co-authored-by: ejagankumar <[email protected]>

* Changed docker file

* package changes

* dockerfile revert

* changed package json

* Update package.json

* reverted other folders

* reverted

* Update settings.json

---------

Co-authored-by: kanishq-egov <[email protected]>
Co-authored-by: kavi_elrey@1993 <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: kanishq-egov <[email protected]>
Co-authored-by: Sathish P <[email protected]>
Co-authored-by: tanishi-egov <[email protected]>
Co-authored-by: Palak Garg <[email protected]>
Co-authored-by: Priyanka-eGov <[email protected]>
Co-authored-by: Jagankumar <[email protected]>
Co-authored-by: nitish-egov <[email protected]>
Co-authored-by: nitish-egov <[email protected]>
Co-authored-by: ansh-egov <[email protected]>
Co-authored-by: ansh-egov <[email protected]>
Co-authored-by: ejagankumar <[email protected]>

* changed package json for debug (#1258)

* boundary code in update flow  to be persisted in db (#1259)

* chnaged header creation logic in generate flow (#1261)

* made few changes for fetching boundaries from boundariesCombined (#1263)

* some boundary bulk and microplan user changes (#1268)

* some boundary bulk and microplan user changes

* Some refactoring

* localisation-cache-fix (#1270)

* localisation-cache-fix

* Refactor

* Refactor

* logger added

* Microplan fix (#1269)

* some boundary bulk and microplan user changes

* Some refactoring

* Fix for target

* Facility fix

* User Fix

* Target valiodation for  microplan

---------

Co-authored-by: ashish-egov <[email protected]>
Co-authored-by: kanishq-egov <[email protected]>
Co-authored-by: kavi_elrey@1993 <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: kanishq-egov <[email protected]>
Co-authored-by: Sathish P <[email protected]>
Co-authored-by: tanishi-egov <[email protected]>
Co-authored-by: Palak Garg <[email protected]>
Co-authored-by: Priyanka-eGov <[email protected]>
Co-authored-by: nitish-egov <[email protected]>
Co-authored-by: nitish-egov <[email protected]>
Co-authored-by: ansh-egov <[email protected]>
Co-authored-by: ansh-egov <[email protected]>
Co-authored-by: ejagankumar <[email protected]>
  • Loading branch information
15 people authored Dec 12, 2024
1 parent fd9a00f commit 8072220
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 67 deletions.
4 changes: 1 addition & 3 deletions health-services/project-factory/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ COPY . .
EXPOSE 3000

CMD ["yarn", "prod"]
# Replaced by CMD ["yarn", "prod"]


# Replaced by CMD ["yarn", "prod"]
4 changes: 2 additions & 2 deletions health-services/project-factory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"build": "yarn run build-ts",
"build-ts": "tsc",
"clean": "rm -rf ./dist",
"serve": "node dist/index.js",
"serve": "if [ \"$DEBUG\" = \"true\" ]; then node --inspect=0.0.0.0:9229 dist/index.js; else node dist/index.js; fi",
"start": "yarn run dev",
"test": "jest",
"dev": "ts-node-dev --respawn src/server/index.ts",
"prod": "yarn build && yarn serve",
"prod": "if [ \"$DEBUG\" = \"true\" ]; then cp tsconfig.debug.json tsconfig.json; fi && yarn build && yarn serve",
"watch-ts": "tsc --watch"
},
"repository": {
Expand Down
5 changes: 5 additions & 0 deletions health-services/project-factory/src/server/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const config = {
},
facility: {
facilityTab: process.env.FACILITY_TAB_NAME || "HCM_ADMIN_CONSOLE_FACILITIES",
facilityCodeColumn : "HCM_ADMIN_CONSOLE_FACILITY_CODE",
facilityType : "facility"
},
user: {
userTab: process.env.USER_TAB_NAME || "HCM_ADMIN_CONSOLE_USER_LIST",
Expand Down Expand Up @@ -95,6 +97,8 @@ const config = {
defaultLocale: process.env.LOCALE || "en_MZ",
boundaryPrefix: "hcm-boundary",
localizationModule: process.env.LOCALIZATION_MODULE || "hcm-admin-schemas",
localizationWaitTimeInBoundaryCreation: parseInt(process.env.LOCALIZATION_WAIT_TIME_IN_BOUNDARY_CREATION || "30000"),
localizationChunkSizeForBoundaryCreation: parseInt(process.env.LOCALIZATION_CHUNK_SIZE_FOR_BOUNDARY_CREATION || "2000"),
},
// targetColumnsForSpecificCampaigns: {
// bedNetCampaignColumns: ["HCM_ADMIN_CONSOLE_TARGET"],
Expand Down Expand Up @@ -148,6 +152,7 @@ const config = {
localizationSearch: process.env.EGOV_LOCALIZATION_SEARCH || "localization/messages/v1/_search",
localizationCreate: "localization/messages/v1/_upsert",
projectTypeSearch: "project-factory/v1/project-type/search",
cacheBurst: process.env.CACHE_BURST || "localization/messages/cache-bust",
boundaryRelationshipCreate: "boundary-service/boundary-relationships/_create",
healthIndividualSearch: process.env.EGOV_HEALTH_INDIVIDUAL_SEARCH || "health-individual/v1/_search",
projectFacilitySearch: process.env.EGOV_HEALTH_PROJECT_FACILITY_SEARCH || "health-project/facility/v1/_search",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { logger } from "../../utils/logger";
import { httpRequest } from "../../utils/request";
import config from "../../config/index";
import { convertLocalisationResponseToMap } from "../../utils/localisationUtils";
import { defaultRequestInfo } from "../../api/coreApis";

let cachedResponse = {};

Expand Down Expand Up @@ -82,6 +83,20 @@ class Localisation {
);
cachedResponse = { ...this.cachedResponse };
};

// Calls the cache burst API of localization
public cacheBurst = async (
) => {
logger.info(`Calling localization cache burst api`);
const RequestInfo = defaultRequestInfo;
const requestBody = {
RequestInfo
}
await httpRequest(
this.localizationHost + config.paths.cacheBurst,
requestBody)
};


private checkCacheAndDeleteIfExists = (module: string, locale: "string") => {
logger.info(
Expand Down Expand Up @@ -132,6 +147,7 @@ class Localisation {
// Log and handle any errors that occur during the process
console.log(e);
logger.error(String(e));
throw new Error(e);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ async function enrichAndPersistCampaignWithError(requestBody: any, error: any) {
requestBody.CampaignDetails.status = campaignStatuses?.failed;
// requestBody.CampaignDetails.isActive = false;
requestBody.CampaignDetails.boundaryCode =
getRootBoundaryCode(requestBody?.CampaignDetails?.boundaries) || null;
getRootBoundaryCode(requestBody?.boundariesCombined) || null;
requestBody.CampaignDetails.projectType =
requestBody?.CampaignDetails?.projectType || null;
requestBody.CampaignDetails.hierarchyType =
Expand Down Expand Up @@ -1035,7 +1035,7 @@ async function enrichAndPersistCampaignForCreate(
request.body.CampaignDetails.status =
action == "create" ? campaignStatuses.started : campaignStatuses.drafted;
request.body.CampaignDetails.boundaryCode = getRootBoundaryCode(
request.body.CampaignDetails.boundaries
request.body?.boundariesCombined
);
request.body.CampaignDetails.projectType =
request?.body?.CampaignDetails?.projectType || null;
Expand Down Expand Up @@ -1111,7 +1111,7 @@ async function enrichAndPersistCampaignForUpdate(
? campaignStatuses.started
: campaignStatuses.drafted;
const boundaryCode = !request?.body?.CampaignDetails?.projectId
? getRootBoundaryCode(request.body.CampaignDetails.boundaries)
? getRootBoundaryCode(request.body?.boundariesCombined)
: request?.body?.CampaignDetails?.boundaryCode ||
ExistingCampaignDetails?.boundaryCode;
request.body.CampaignDetails.boundaryCode = boundaryCode;
Expand Down Expand Up @@ -2414,6 +2414,7 @@ async function processAfterPersist(request: any, actionInUrl: any) {
localizationMap
);
}
delete request.body?.boundariesCombined;
} catch (error: any) {
console.log(error);
logger.error(error);
Expand Down
52 changes: 28 additions & 24 deletions health-services/project-factory/src/server/utils/genericUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ async function fullProcessFlowForNewEntry(newEntryResponse: any, generatedResour
const localizationMapModule = await getLocalizedMessagesHandler(request, request?.query?.tenantId);
const localizationMap = { ...localizationMapHierarchy, ...localizationMapModule };
let fileUrlResponse: any;
if(type != 'boundaryManagement' && request?.query?.campaignId != 'default' && type != 'boundaryGeometryManagement'){
if (type != 'boundaryManagement' && request?.query?.campaignId != 'default' && type != 'boundaryGeometryManagement') {
const responseFromCampaignSearch = await getCampaignSearchResponse(request);
const campaignObject = responseFromCampaignSearch?.CampaignDetails?.[0];
logger.info(`checks for parent campaign for type: ${type}`)
Expand Down Expand Up @@ -407,7 +407,7 @@ async function fullProcessFlowForNewEntry(newEntryResponse: any, generatedResour
await produceModifiedMessages(generatedResourceNew, updateGeneratedResourceTopic);
request.body.generatedResource = finalResponse;
}
else if (type == 'boundaryManagement' || type === 'boundaryGeometryManagement'){
else if (type == 'boundaryManagement' || type === 'boundaryGeometryManagement') {
// get boundary data from boundary relationship search api
logger.info("Generating Boundary Data")
const boundaryDataSheetGeneratedBeforeDifferentTabSeparation = await getBoundaryDataService(request, false);
Expand Down Expand Up @@ -601,10 +601,10 @@ function setAndFormatHeaders(worksheet: any, mainHeader: any, headerSet: any) {
async function createReadMeSheet(request: any, workbook: any, mainHeader: any, localizationMap = {}) {
const isSourceMicroplan = await isMicroplanRequest(request);
let readMeConfig: any;
if(isSourceMicroplan) {
if (isSourceMicroplan) {
readMeConfig = await getReadMeConfigForMicroplan(request);
}
else{
else {
readMeConfig = await getReadMeConfig(request);
}
const headerSet = new Set();
Expand Down Expand Up @@ -749,13 +749,13 @@ async function createFacilityAndBoundaryFile(facilitySheetData: any, boundaryShe
hideUniqueIdentifierColumn(facilitySheet, createAndSearch?.["facility"]?.uniqueIdentifierColumn);
changeFirstRowColumnColour(facilitySheet, 'E06666');

let receivedDropdowns=request.body?.dropdowns;
logger.info("started adding dropdowns in facility",JSON.stringify(receivedDropdowns))
let receivedDropdowns = request.body?.dropdowns;
logger.info("started adding dropdowns in facility", JSON.stringify(receivedDropdowns))

if(!receivedDropdowns||Object.keys(receivedDropdowns)?.length==0){
if (!receivedDropdowns || Object.keys(receivedDropdowns)?.length == 0) {
logger.info("No dropdowns found");
receivedDropdowns= setDropdownFromSchema(request,schema,localizationMap);
logger.info("refetched drodowns",JSON.stringify(receivedDropdowns))
receivedDropdowns = setDropdownFromSchema(request, schema, localizationMap);
logger.info("refetched drodowns", JSON.stringify(receivedDropdowns))
}
await handledropdownthings(facilitySheet, receivedDropdowns);
await handleHiddenColumns(facilitySheet, request.body?.hiddenColumns);
Expand All @@ -777,7 +777,7 @@ async function handledropdownthings(sheet: any, dropdowns: any) {
logger.info("Dropdowns provided:", dropdowns);
for (const key of Object.keys(dropdowns)) {
if (dropdowns[key]) {
logger.info(`Processing dropdown key: ${key} with values: ${dropdowns[key]}`);
logger.info(`Processing dropdown key: ${key} with values: ${dropdowns[key]}`);
const firstRow = sheet.getRow(1);
firstRow.eachCell({ includeEmpty: true }, (cell: any, colNumber: any) => {
if (cell.value === key) {
Expand Down Expand Up @@ -815,7 +815,7 @@ async function handledropdownthings(sheet: any, dropdowns: any) {

async function handleHiddenColumns(sheet: any, hiddenColumns: any) {
// logger.info(sheet)
logger.info("hiddenColumns",hiddenColumns);
logger.info("hiddenColumns", hiddenColumns);
if (hiddenColumns) {
for (const columnName of hiddenColumns) {
const firstRow = sheet.getRow(1);
Expand Down Expand Up @@ -849,13 +849,13 @@ async function createUserAndBoundaryFile(userSheetData: any, boundarySheetData:
addDataToSheet(request, userSheet, userSheetData, undefined, undefined, true, false, localizationMap, fileUrl, schema);
hideUniqueIdentifierColumn(userSheet, createAndSearch?.["user"]?.uniqueIdentifierColumn);

let receivedDropdowns=request.body?.dropdowns;
logger.info("started adding dropdowns in user",JSON.stringify(receivedDropdowns))
let receivedDropdowns = request.body?.dropdowns;
logger.info("started adding dropdowns in user", JSON.stringify(receivedDropdowns))

if(!receivedDropdowns||Object.keys(receivedDropdowns)?.length==0){
if (!receivedDropdowns || Object.keys(receivedDropdowns)?.length == 0) {
logger.info("No dropdowns found");
receivedDropdowns= setDropdownFromSchema(request,schema,localizationMap);
logger.info("refetched drodowns",JSON.stringify(receivedDropdowns))
receivedDropdowns = setDropdownFromSchema(request, schema, localizationMap);
logger.info("refetched drodowns", JSON.stringify(receivedDropdowns))
}
await handledropdownthings(userSheet, receivedDropdowns);
await handleHiddenColumns(userSheet, request.body?.hiddenColumns);
Expand All @@ -870,6 +870,8 @@ async function createUserAndBoundaryFile(userSheetData: any, boundarySheetData:


async function generateFacilityAndBoundarySheet(tenantId: string, request: any, localizationMap?: { [key: string]: string }, filteredBoundary?: any, fileUrl?: any) {
const type = request?.query?.type || request?.body?.ResourceDetails?.type;
const typeWithoutWith = type.includes('With') ? type.split('With')[0] : type;
// Get facility and boundary data
logger.info("Generating facilities started");
const allFacilities = await getAllFacilities(tenantId, request.body);
Expand All @@ -881,10 +883,10 @@ async function generateFacilityAndBoundarySheet(tenantId: string, request: any,
if (fileUrl) {
/* fetch facility from processed file
and generate facility sheet data */
schema = await callMdmsTypeSchema(request, tenantId, true, typeWithoutWith, "all");
const processedFacilitySheetData = await getSheetData(fileUrl, localizedFacilityTab, false, undefined, localizationMap);
const modifiedProcessedFacilitySheetData = modifyProcessedSheetData(request, processedFacilitySheetData, localizationMap);
const modifiedProcessedFacilitySheetData = modifyProcessedSheetData(typeWithoutWith, processedFacilitySheetData, schema, localizationMap);
facilitySheetData = modifiedProcessedFacilitySheetData;
schema = await callMdmsTypeSchema(request, tenantId, true, "facility", "all");
setDropdownFromSchema(request, schema, localizationMap);
}
else {
Expand All @@ -903,9 +905,11 @@ async function generateFacilityAndBoundarySheet(tenantId: string, request: any,

async function generateUserSheet(request: any, localizationMap?: { [key: string]: string }, filteredBoundary?: any, userData?: any, fileUrl?: any) {
const tenantId = request?.query?.tenantId;
const type = request?.query?.type || request?.body?.ResourceDetails?.type;
const typeWithoutWith = type.includes('With') ? type.split('With')[0] : type;
let schema: any;
const isUpdate = fileUrl ? true : false;
schema = await callMdmsTypeSchema(request, tenantId, isUpdate, "user");
schema = await callMdmsTypeSchema(request, tenantId, isUpdate, typeWithoutWith);
setDropdownFromSchema(request, schema, localizationMap);
const headers = schema?.columns;
const localizedHeaders = getLocalizedHeaders(headers, localizationMap);
Expand All @@ -917,7 +921,7 @@ async function generateUserSheet(request: any, localizationMap?: { [key: string]
/* fetch facility from processed file
and generate facility sheet data */
const processedUserSheetData = await getSheetData(fileUrl, localizedUserTab, false, undefined, localizationMap);
const modifiedProcessedUserSheetData = modifyProcessedSheetData(request, processedUserSheetData, localizationMap);
const modifiedProcessedUserSheetData = modifyProcessedSheetData(typeWithoutWith, processedUserSheetData, schema, localizationMap);
userSheetData = modifiedProcessedUserSheetData;
}
else {
Expand Down Expand Up @@ -1075,7 +1079,7 @@ async function handleGenerateError(newEntryResponse: any, generatedResource: any
code: error.code,
description: error.description,
message: error.message
} || String(error)
}
}
})
generatedResource = { generatedResource: newEntryResponse };
Expand Down Expand Up @@ -1303,12 +1307,12 @@ async function getDataSheetReady(boundaryData: any, request: any, localizationMa
mappedRowData[boundaryCodeIndex] = boundaryCode;
return mappedRowData;
});
if(type == "boundaryManagement"){
if (type == "boundaryManagement") {
logger.info("Processing data for boundaryManagement type")
const latLongBoundaryMap = await getLatLongMapForBoundaryCodes(request, boundaryCodeList);
for (let d of data) {
const boundaryCode = d[d.length - 1]; // Assume last element is the boundary code

if (latLongBoundaryMap[boundaryCode]) {
const [latitude = null, longitude = null] = latLongBoundaryMap[boundaryCode]; // Destructure lat/long
d.push(latitude); // Append latitude
Expand Down Expand Up @@ -1359,7 +1363,7 @@ function modifyDataBasedOnDifferentTab(boundaryData: any, differentTabsBasedOnLe
async function getLocalizedMessagesHandler(request: any, tenantId: any, module = config.localisation.localizationModule, overrideCache = false) {
const localisationcontroller = Localisation.getInstance();
const locale = getLocaleFromRequest(request);
const localizationResponse = await localisationcontroller.getLocalisedData(module, locale, tenantId,overrideCache);
const localizationResponse = await localisationcontroller.getLocalisedData(module, locale, tenantId, overrideCache);
return localizationResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ export async function getUserDataFromMicroplanSheet(request: any, fileStoreId: a
export function getAllUserData(request: any, userMapping: any, localizationMap: any) {
const emailKey = getLocalizedName("HCM_ADMIN_CONSOLE_USER_EMAIL_MICROPLAN", localizationMap);
const nameKey = getLocalizedName("HCM_ADMIN_CONSOLE_USER_NAME_MICROPLAN", localizationMap);
const phoneNumberKey = getLocalizedName("HCM_ADMIN_CONSOLE_USER_PHONE_NUMBER_MICROPLAN", localizationMap);
validateInConsistency(request, userMapping, emailKey, nameKey);
validateNationalDuplicacy(request, userMapping, phoneNumberKey);
validateNationalDuplicacy(request, userMapping, localizationMap);
const dataToCreate: any = [];
for (const phoneNumber of Object.keys(userMapping)) {
const roles = userMapping[phoneNumber].map((user: any) => user.role).join(',');
Expand Down Expand Up @@ -94,30 +93,30 @@ function validateInConsistency(request: any, userMapping: any, emailKey: any, na
request.body.sheetErrorDetails = Array.isArray(request.body.sheetErrorDetails) ? [...request.body.sheetErrorDetails, ...overallInconsistencies] : overallInconsistencies;
}

function validateNationalDuplicacy(request: any, userMapping: any, phoneNumberKey: any) {
function validateNationalDuplicacy(request: any, userMapping: any, localizationMap: any) {
const duplicates: any[] = [];

for (const phoneNumber in userMapping) {
const roleMap: any = {};
const users = userMapping[phoneNumber];

for (const user of users) {
if (user.role?.startsWith("Root ")) {
const userRole = user?.role;
if (userRole?.startsWith("ROOT_")) {
// Trim the role
const trimmedRole = user.role.replace("Root ", "").trim().toLowerCase();
const trimmedRoleWithCapital = trimmedRole.charAt(0).toUpperCase() + trimmedRole.slice(1);
const trimmedRole = userRole.replace("ROOT_", "");

// Check for duplicates in the roleMap
if (roleMap[trimmedRole] && roleMap[trimmedRole]["!sheet#name!"] != user["!sheet#name!"]) {
const errorMessage: any = `An user with ${trimmedRoleWithCapital} role can’t be assigned to ${user.role} role`;
const errorMessage: any = `An user with ${getLocalizedName(trimmedRole, localizationMap)} role can’t be assigned to ${getLocalizedName(userRole, localizationMap)} role`;
duplicates.push({ rowNumber: user["!row#number!"], sheetName: user["!sheet#name!"], status: "INVALID", errorDetails: errorMessage });
} else {
roleMap[trimmedRole] = user;
}
}
else {
const trimmedRole = user.role.toLowerCase();
const errorMessage: any = `An user with ${"Root " + trimmedRole} role can’t be assigned to ${user.role} role`;
const trimmedRole = userRole;
const errorMessage: any = `An user with ${getLocalizedName("ROOT_" + trimmedRole, localizationMap)} role can’t be assigned to ${getLocalizedName(userRole, localizationMap)} role`;
if (roleMap[trimmedRole] && roleMap[trimmedRole]["!sheet#name!"] != user["!sheet#name!"]) {
duplicates.push({ rowNumber: user["!row#number!"], sheetName: user["!sheet#name!"], status: "INVALID", errorDetails: errorMessage });
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function getCreatedResourceIds(resources: any, type: any) {
const processedType = type === 'boundary'
? 'boundaryWithTarget'
: (type.includes('With') ? type.split('With')[0] : type);
return resources
.filter((item: any) => item.type === processedType)
.map((item: any) => item.createResourceId);
return resources
.filter((item: any) => item.type === processedType)
.map((item: any) => item.createResourceId);
}

function buildSearchCriteria(request: any, createdResourceId: any, type: any) {
Expand Down Expand Up @@ -76,23 +76,10 @@ async function fetchFileUrls(request: any, processedFileStoreIdForUSerOrFacility



function modifyProcessedSheetData(request: any, sheetData: any, localizationMap?: any) {
// const type = request?.query?.type || request?.body?.ResourceDetails?.type;
// const typeWithoutWith = type.includes('With') ? type.split('With')[0] : type;
function modifyProcessedSheetData(type: any, sheetData: any, schema: any, localizationMap?: any) {
if (!sheetData || sheetData.length === 0) return [];

// Find the row with the maximum number of keys
const maxLengthRow = sheetData.reduce((maxRow: any, row: any) => {
return Object.keys(row).length > Object.keys(maxRow).length ? row : maxRow;
}, {});

// Extract headers from the keys of the row with the maximum number of keys
const originalHeaders = Object.keys(maxLengthRow);
const statusIndex = originalHeaders.indexOf('#status#');
// Insert 'errordetails' after '#status#' if found
if (statusIndex !== -1) {
originalHeaders.splice(statusIndex + 1, 0, '#errorDetails#');
}
const originalHeaders = type === config?.facility?.facilityType ? [config?.facility?.facilityCodeColumn, ...schema?.columns] : schema?.columns;

let localizedHeaders = getLocalizedHeaders(originalHeaders, localizationMap);

Expand Down
Loading

0 comments on commit 8072220

Please sign in to comment.