From 0321e0f196172851d8ebb8edc9728c770b1bb9fa Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 27 Nov 2023 17:33:57 +1100 Subject: [PATCH] Script to add service labels to new programs #3030 --- .../3.1/adhoc/addNhtLabelsToNewPrograms.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/scripts/releases/3.1/adhoc/addNhtLabelsToNewPrograms.js diff --git a/src/main/scripts/releases/3.1/adhoc/addNhtLabelsToNewPrograms.js b/src/main/scripts/releases/3.1/adhoc/addNhtLabelsToNewPrograms.js new file mode 100644 index 000000000..e40033e16 --- /dev/null +++ b/src/main/scripts/releases/3.1/adhoc/addNhtLabelsToNewPrograms.js @@ -0,0 +1,28 @@ +const programs = [ + 'Priority Species - Procurements', + 'World Heritage Protection', + 'Ramsar Wetland Protection', + 'Priority Places', + 'Priority Species', + 'Saving Native Species' +]; +var programToCopyLabels = db.program.findOne({name:'Recovery Actions for Species and Landscapes'}); + +let services = db.service.find({programLabels:{$ne:null}}); +while(services.hasNext()) { + let service = services.next(); + let label = service.programLabels[programToCopyLabels.programId]; + + if (!label) { + print("No label found for service " + service.name); + printjson(service); + throw "Help!"; + } + + for (let i=0; i