Skip to content

Commit

Permalink
Merge pull request #3344 from AtlasOfLivingAustralia/feature/issues3343
Browse files Browse the repository at this point in the history
#3343 update form version for reports
  • Loading branch information
chrisala authored Oct 10, 2024
2 parents 6cf1f74 + 1be5d7f commit 8c452d7
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load('../../utils/audit.js');
var programId = "834f6ec8-100b-44c2-9527-72d12d6edd89", projects = [], reports = [], activities = [],
reportName= "Progress Report 1", activities = [], newFormVersion = NumberInt(1), counter = 0,
user="system";

db.project.find({programId: programId}).forEach(function(project) {
projects.push(project.projectId);
});
print("Projects: " + projects.length);
db.report.find({projectId: {$in: projects}, name: reportName }).forEach(function(report) {
reports.push(report.reportId);
activities.push(report.activityId);
});

print("Reports length " + reports.length + " reports list " + reports);
db.activity.find({activityId: {$in: activities}, progress: "planned"}).forEach(function(activity) {
if (!activity.formVersion) {
activity.formVersion = newFormVersion;
db.activity.updateOne({activityId: activity.activityId}, {$set: {formVersion: newFormVersion}});
audit(activity, activity.activityId, 'au.org.ala.ecodata.Activity', user);
print("Activity " + activity.activityId + " updated.");
counter++;
}
});

print("Activities: " + activities.length + " Updated: " + counter);

0 comments on commit 8c452d7

Please sign in to comment.