Skip to content

Commit 1b27fb5

Browse files
committed
Remove not required status from some reports #3051
1 parent 1e8730c commit 1b27fb5

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
load('../../../utils/reports.js');
2+
load('../../../utils/audit.js');
3+
const adminUserId = '1493';
4+
const reportIds = [];
5+
6+
const grantIds = [
7+
'ASP-MU05-P1',
8+
'ASP-MU38-P1',
9+
'ASP-MU37-P1',
10+
'ASP-MU12-P1',
11+
'ASP-MU20-P1',
12+
'ASP-MU44-P1',
13+
'ASP-MU42-P1',
14+
'ASP-MU16-P1',
15+
'ASP-MU28-P1',
16+
'ASP-MU41-P1',
17+
'ASP-MU26-P1',
18+
];
19+
20+
21+
for (let i=0; i<grantIds.length; i++) {
22+
let project = db.project.findOne({grantId:grantIds[i]});
23+
24+
let report = db.report.findOne({projectId:project.projectId, activityType:'Annual Report 2022', toDate:{$gte:project.plannedEndDate}});
25+
26+
if (!report) {
27+
throw "Uhoh, found no report for project "+grantIds[i];
28+
}
29+
else {
30+
print("Found report "+report.name);
31+
}
32+
33+
removeNotRequiredStatus(report.reportId, 'Extending project end date', adminUserId);
34+
35+
}

src/main/scripts/utils/reports.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ function removeNotRequiredStatus(reportId, reason, adminUserId) {
121121
"dateChanged" : ISODate(),
122122
"status" : report.publicationStatus
123123
});
124-
db.report.save(report);
124+
db.report.replaceOne({_id:report._id}, report);
125125
audit(report, report.reportId, 'au.org.ala.ecodata.Report', adminUserId);
126126

127127
if (report.activityId) {
128128
var activity = db.activity.findOne({activityId:report.activityId});
129129
activity.publicationStatus = 'unpublished';
130-
db.activity.save(activity);
130+
db.activity.replaceOne({_id:activity._id}, activity);
131131
audit(activity, activity.activityId, 'au.org.ala.ecodata.Activity', adminUserId);
132132
}
133133
}

0 commit comments

Comments
 (0)