-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3344 from AtlasOfLivingAustralia/feature/issues3343
#3343 update form version for reports
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/scripts/releases/4.1/adhoc/forceSelectFormVersionForReports.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |