Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- update form version for reports
  • Loading branch information
temi committed Oct 10, 2024
1 parent 6cf1f74 commit e576787
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var programId = "834f6ec8-100b-44c2-9527-72d12d6edd89", projects = [], reports = [], activities = [],
reportName= "Progress Report 1", activities = [], newFormVersion = NumberInt(1), counter = 0;

db.project.find({programId: programId}).forEach(function(program) {
projects.push(program.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) {
db.activity.updateOne({activityId: activity.activityId}, {$set: {formVersion: newFormVersion}});
print("Activity " + activity.activityId + " updated.");
counter++;
}
});

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

0 comments on commit e576787

Please sign in to comment.