Skip to content

Commit

Permalink
docs(script): add scripts to privatize all sp/rp student forms (#2073)
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui authored Jun 4, 2021
1 parent 7305b83 commit e809a50
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
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()
}
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()
}

0 comments on commit e809a50

Please sign in to comment.