-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(script): add scripts to privatize all sp/rp student forms (#2073)
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
scripts/20210604_private-rp-sp-student-forms/private-rp-stud-forms.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,45 @@ | ||
/* eslint-disable */ | ||
|
||
// BEFORE | ||
// A: Count number of forms belonging to RP students that are still public. | ||
{ | ||
let rpStudentUserIds = db.users.find({ email: /.+myrp\.edu\.sg$/i }).map(b => b._id) | ||
db.forms.find({ admin: { $in: rpStudentUserIds }, status: 'PUBLIC' }).count() | ||
} | ||
// B: Count number of forms belonging to RP students that are private. | ||
{ | ||
let rpStudentUserIds = db.users.find({ email: /.+myrp\.edu\.sg$/i }).map(b => b._id) | ||
db.forms.find({ admin: { $in: rpStudentUserIds }, status: 'PRIVATE' }).count() | ||
} | ||
|
||
// UPDATE | ||
// Number updated should be A | ||
{ | ||
let rpStudentUserIds = db.users.find({ email: /.+myrp\.edu\.sg$/i }).map(b => b._id) | ||
let rpStudentFormIds = db.forms.find({ admin: { $in: rpStudentUserIds }, status: 'PUBLIC' }).map(b => b._id) | ||
|
||
db.forms.updateMany( | ||
{ | ||
_id: { $in: rpStudentFormIds }, | ||
}, | ||
{ | ||
$set: { | ||
status: 'PRIVATE', | ||
}, | ||
} | ||
) | ||
} | ||
|
||
// AFTER | ||
// Count number of forms belonging to RP students that are still public | ||
// Should be 0 | ||
{ | ||
let rpStudentUserIds = db.users.find({ email: /.+myrp\.edu\.sg$/i }).map(b => b._id) | ||
db.forms.find({ admin: { $in: rpStudentUserIds }, status: 'PUBLIC' }).count() | ||
} | ||
// Count number of forms belonging to RP students that are private. | ||
// Should be A + B | ||
{ | ||
let rpStudentUserIds = db.users.find({ email: /.+myrp\.edu\.sg$/i }).map(b => b._id) | ||
db.forms.find({ admin: { $in: rpStudentUserIds }, status: 'PRIVATE' }).count() | ||
} |
45 changes: 45 additions & 0 deletions
45
scripts/20210604_private-rp-sp-student-forms/private-sp-stud-forms.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,45 @@ | ||
/* eslint-disable */ | ||
|
||
// BEFORE | ||
// A: Count number of forms belonging to SP students that are still public. | ||
{ | ||
let spStudentUserIds = db.users.find({ email: /.+ichat\.sp\.edu\.sg$/i }).map(b => b._id) | ||
db.forms.find({ admin: { $in: spStudentUserIds }, status: 'PUBLIC' }).count() | ||
} | ||
// B: Count number of forms belonging to SP students that are private. | ||
{ | ||
let spStudentUserIds = db.users.find({ email: /.+ichat\.sp\.edu\.sg$/i }).map(b => b._id) | ||
db.forms.find({ admin: { $in: spStudentUserIds }, status: 'PRIVATE' }).count() | ||
} | ||
|
||
// UPDATE | ||
// Number updated should be A | ||
{ | ||
let spStudentUserIds = db.users.find({ email: /.+ichat\.sp\.edu\.sg$/i }).map(b => b._id) | ||
let spStudentFormIds = db.forms.find({ admin: { $in: spStudentUserIds }, status: 'PUBLIC' }).map(b => b._id) | ||
|
||
db.forms.updateMany( | ||
{ | ||
_id: { $in: spStudentFormIds }, | ||
}, | ||
{ | ||
$set: { | ||
status: 'PRIVATE', | ||
}, | ||
} | ||
) | ||
} | ||
|
||
// AFTER | ||
// Count number of forms belonging to SP students that are still public | ||
// Should be 0 | ||
{ | ||
let spStudentUserIds = db.users.find({ email: /.+ichat\.sp\.edu\.sg$/i }).map(b => b._id) | ||
db.forms.find({ admin: { $in: spStudentUserIds }, status: 'PUBLIC' }).count() | ||
} | ||
// Count number of forms belonging to SP students that are private. | ||
// Should be A + B | ||
{ | ||
let spStudentUserIds = db.users.find({ email: /.+ichat\.sp\.edu\.sg$/i }).map(b => b._id) | ||
db.forms.find({ admin: { $in: spStudentUserIds }, status: 'PRIVATE' }).count() | ||
} |