Closed rafinkanisa closed 2 years ago
Created nodejs script to update organization collection with data imported from csv file. Functionally similar to mongoimport --upsert
which can't do partial update in version 3.0. Still in test.
organization_name
values in organization
collectionUsing mongo-update-csv.js
script to import data from csv file and update the organization_name
field, filter by admin0pcode
, organization_tag
fields in organization
collection.
node mongo-update-csv.js update-org-name.csv --filterFields admin0pcode,organization_tag --updateFields organization_name -d ngmReportHub -c organization
file update-org-name.csv
admin0pcode,organization_tag,organization_name
AF,ancc,Afghanistan National Re-Construction Coordination
AF,cww,Concern World Wide
AF,frdo,Female Rehabilitation Development Organization
AF,hadaf,Humanitarian Assistance and Development Association for Afghanistan
AF,icrc,International Committee of the Red Cross and Red Crescent
AF,sfl,Shelter For Life International
AF,unmas,United Nations Mine Action Service
AF,zoa,ZOA International
ET,cww,Concern World Wide
ET,unocha,Office for the Coordination of Humanitarian Affairs
organization
values in organization
collectionUsing mongo-update-csv.js
script to import data from csv file and update the organization
field, filter by admin0pcode
, organization_tag
fields in organization
collection.
node mongo-update-csv.js update-org.csv --filterFields admin0pcode,organization_tag --updateFields organization -d ngmReportHub -c organization
file update-org.csv
admin0pcode,organization_tag,organization
AF,shuhada,SHUHADA
AF,me,ME
ET,ndrmc,NDRMC
organization
, organization_name
values in user
collectionUsing update_organizations_data_in_user.js
script to update organization
, organization_name
data in user
collection using data from organization
collection.
mongo localhost:27017/ngmReportHub update_organizations_data_in_user.js --eval 'var admin0pcode="ET"'
organization
collectionDuplicate organization
that organization
, organization_name
, and organization_type
values have been made uniform can be removed/deduplicated using find_refs_to_duplicate_orgs.js
script. Set admin0pcode = "ET"
inside the script or from mongo shell --eval
param.
// open mongo shell with find_refs_to_duplicate_orgs.js script
mongo localhost:27017/ngmHealthCluster find_refs_to_duplicate_orgs.js --eval 'var admin0pcode="ET"' --shell
// delete duplicate organizations
delete_duplicate_organizations()
// update references to duplicate organizations
update_refs_to_duplicate_orgs()
already tested on DEV Server
already on PROD
Describe the bug Similar to https://github.com/iMMAP/ngm-reportDesk/issues/39
Context I found this when I'm trying to add organization and check on the database
To Reproduce Steps to reproduce the behavior:
Expected behavior Any of the organization details in other related collections (e.g. user) should follow with collections "organization". This applies to all reporting collection as well. The organization collection shall refer the details to organizations collection.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context You might have to delete the unused value in organization collection if it's duplicated / the organization shouldn't be active in that country (refer to organizations collection) In case you have doubt which action shall you taken, you can always consult me first