From f4960df5287276149b10d6146a990bf8d26dd215 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Thu, 25 Feb 2021 10:18:49 +0000 Subject: [PATCH] [Trunk | Admin Tools]: 1. update_db.js: Added method to add Piwik ids for each community (check ids before running it). 2. migrateCommunityIn_db.js: Added method to migrate curators (there was an error with null fields - UI needs them empty strings). --- migrateCommunityIn_db.js | 101 ++++++++++++++++++++++++++++++--------- update_db.js | 31 +++++++++++- 2 files changed, 108 insertions(+), 24 deletions(-) diff --git a/migrateCommunityIn_db.js b/migrateCommunityIn_db.js index b1d54eb..e26d2ac 100644 --- a/migrateCommunityIn_db.js +++ b/migrateCommunityIn_db.js @@ -195,29 +195,84 @@ function migrate_portal(portalPid, beta_db_name, prod_db_name) { } -migrate_portal("aginfra", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("rural-digital-europe", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("clarin", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("enermaps", 'openaireconnect_new', 'openaireconnect'); -// migrate_portal("ifremer", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("instruct", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("risis", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("rda", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("science-innovation-policy", 'openaireconnect_new', 'openaireconnect'); -// migrate_portal("sobigdata", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("sdsn-gr", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("elixir-gr", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("beopen", 'openaireconnect_new', 'openaireconnect'); -// migrate_portal("euromarine", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("oa-pg", 'openaireconnect_new', 'openaireconnect'); +function migrateCurators(beta_db_name, prod_db_name) { + beta_db = db.getSiblingDB(beta_db_name); + // beta_db.auth("your_username", "your_password"); + prod_db = db.getSiblingDB(prod_db_name); + // prod_db.auth("your_username", "your_password"); -migrate_portal("covid-19", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("dariah", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("dh-ch", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("egi", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("mes", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("epos", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("fam", 'openaireconnect_new', 'openaireconnect'); -migrate_portal("ni", 'openaireconnect_new', 'openaireconnect'); + print("migrateCurators: both dbs are here"); + // migrate curators of portal + var beta_curators = beta_db.curator.find().forEach(function(beta_curator) { + if (beta_curator) { + prod_db.curator.remove({"email": beta_curator.email}); + curator = {}; + curator['_id'] = beta_curator._id; // this is aaiId + + if(beta_curator.email) { + curator['email'] = beta_curator.email; + } else { + curator['email'] = ""; + } + + if(beta_curator.name) { + curator['name'] = beta_curator.name; + } else { + curator['name'] = ""; + } + + if(beta_curator.affiliations) { + curator['affiliations'] = beta_curator.affiliations; + } else { + curator['affiliations'] = []; + } + + if(beta_curator.photo) { + curator['photo'] = beta_curator.photo; + } else { + curator['photo'] = ""; + } + + if(beta_curator.bio) { + curator['bio'] = beta_curator.bio; + } else { + curator['bio'] = ""; + } + // prod_db.curator.insert({"email": beta_curator.email,"name": beta_curator.name, "affiliations": beta_curator.affiliations, "photo": beta_curator.photo, "bio": beta_curator.bio}); + prod_db.curator.insert(curator); + + print("curator "+beta_curator.name + " is migrated"); + } + }); +} + +// migrate_portal("aginfra", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("rural-digital-europe", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("clarin", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("enermaps", 'openaireconnect_new', 'openaireconnect'); +// // migrate_portal("ifremer", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("instruct", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("risis", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("rda", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("science-innovation-policy", 'openaireconnect_new', 'openaireconnect'); +// // migrate_portal("sobigdata", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("sdsn-gr", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("elixir-gr", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("beopen", 'openaireconnect_new', 'openaireconnect'); +// // migrate_portal("euromarine", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("oa-pg", 'openaireconnect_new', 'openaireconnect'); +// +// +// migrate_portal("covid-19", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("dariah", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("dh-ch", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("egi", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("mes", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("epos", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("fam", 'openaireconnect_new', 'openaireconnect'); +// migrate_portal("ni", 'openaireconnect_new', 'openaireconnect'); +// + +migrateCurators("openaireconnect_new", "openaireconnect"); diff --git a/update_db.js b/update_db.js index c104fb8..64b9caf 100644 --- a/update_db.js +++ b/update_db.js @@ -1693,6 +1693,32 @@ function addPortalPidInLayoutRecords() { } } +// 22-10-2020 +function addPiwik() { + db.portal.update({"pid": "openaire"}, {$set: {piwik:"6"}}); + db.portal.update({"pid": "connect"}, {$set: {piwik:"80"}}); + db.portal.update({"pid": "dh-ch"}, {$set: {piwik:"81"}}); + db.portal.update({"pid": "ee"}, {$set: {piwik:"82"}}); + db.portal.update({"pid": "egi"}, {$set: {piwik:"83"}}); + db.portal.update({"pid": "elixir-gr"}, {$set: {piwik:"84"}}); + db.portal.update({"pid": "fam"}, {$set: {piwik:"85"}}); + db.portal.update({"pid": "instruct"}, {$set: {piwik:"86"}}); + db.portal.update({"pid": "mes"}, {$set: {piwik:"87"}}); + db.portal.update({"pid": "ni"}, {$set: {piwik:"88"}}); + db.portal.update({"pid": "oa-pg"}, {$set: {piwik:"89"}}); + db.portal.update({"pid": "rda"}, {$set: {piwik:"90"}}); + db.portal.update({"pid": "aginfra"}, {$set: {piwik:"93"}}); + db.portal.update({"pid": "clarin"}, {$set: {piwik:"100"}}); + db.portal.update({"pid": "dariah"}, {$set: {piwik:"103"}}); + db.portal.update({"pid": "epos"}, {$set: {piwik:"217"}}); + db.portal.update({"pid": "beopen"}, {$set: {piwik:"218"}}); + db.portal.update({"pid": "risis"}, {$set: {piwik:"219"}}); + db.portal.update({"pid": "science-innovation-policy"}, {$set: {piwik:"253"}}); + db.portal.update({"pid": "covid-19"}, {$set: {piwik:"267"}}); + db.portal.update({"pid": "rural-digital-europe"}, {$set: {piwik:"319"}}); + db.portal.update({"pid": "enermaps"}, {$set: {piwik:"318"}}); +} + use openaireconnect; //updatePages(); @@ -1764,4 +1790,7 @@ addPortalType(); createPagesForEachPortalType(); createDivIdsForEachPortalType(); renameCollectionAndFields(); -addPortalPidInLayoutRecords(); \ No newline at end of file +addPortalPidInLayoutRecords(); + +// 22-10-2020 +// addPiwik(); \ No newline at end of file