Skip to content

Commit 8c452d7

Browse files
authored
Merge pull request #3344 from AtlasOfLivingAustralia/feature/issues3343
#3343 update form version for reports
2 parents 6cf1f74 + 1be5d7f commit 8c452d7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load('../../utils/audit.js');
2+
var programId = "834f6ec8-100b-44c2-9527-72d12d6edd89", projects = [], reports = [], activities = [],
3+
reportName= "Progress Report 1", activities = [], newFormVersion = NumberInt(1), counter = 0,
4+
user="system";
5+
6+
db.project.find({programId: programId}).forEach(function(project) {
7+
projects.push(project.projectId);
8+
});
9+
print("Projects: " + projects.length);
10+
db.report.find({projectId: {$in: projects}, name: reportName }).forEach(function(report) {
11+
reports.push(report.reportId);
12+
activities.push(report.activityId);
13+
});
14+
15+
print("Reports length " + reports.length + " reports list " + reports);
16+
db.activity.find({activityId: {$in: activities}, progress: "planned"}).forEach(function(activity) {
17+
if (!activity.formVersion) {
18+
activity.formVersion = newFormVersion;
19+
db.activity.updateOne({activityId: activity.activityId}, {$set: {formVersion: newFormVersion}});
20+
audit(activity, activity.activityId, 'au.org.ala.ecodata.Activity', user);
21+
print("Activity " + activity.activityId + " updated.");
22+
counter++;
23+
}
24+
});
25+
26+
print("Activities: " + activities.length + " Updated: " + counter);

0 commit comments

Comments
 (0)