Skip to content

Commit

Permalink
Adds --complete option to removal script
Browse files Browse the repository at this point in the history
  • Loading branch information
typeoneerror committed May 21, 2024
1 parent ce1c604 commit 8fd14ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
34 changes: 22 additions & 12 deletions examples/nm/bulk-member-remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@ const { findAndRemoveCircleMember } = require('../shared/circle');
const { findAndTagConvertkitSubscriber } = require('../shared/convertkit');
const { RED_COLOR, yargs } = require('../shared/scim');

const argv = yargs.option('i', {
alias: 'id',
type: 'string',
describe: 'The ID of the Student in the Student database',
}).argv;
const argv = yargs
.option('i', {
alias: 'id',
type: 'string',
describe: 'The ID of the Student in the Student database',
})
.option('c', {
alias: 'complete',
type: 'boolean',
describe: 'Totally remove the Student from the NOTION MASTERY workspace?',
default: false,
}).argv;

const RPS = 1;
const limit = RateLimit(RPS);
const DIV = '~~~~~~~~~~';

async function removeMember(user) {
async function removeMember(user, complete = false) {
await limit();

const memberName = user['Name'];
Expand All @@ -34,11 +41,14 @@ async function removeMember(user) {
const member = await findMember(NMID);

if (member) {
// Remove entirely...
// await removeMemberFromWorkspace(NMID);

// Remove from Notion Mastery group but keep in workspace
await removeMemberFromGroup('7d3e5712-a873-43a8-a4b5-2ab138a9e2ea', NMID);
if (complete) {
// Remove entirely...
await removeMemberFromWorkspace(NMID);
} else {
// Remove from Notion Mastery groups but keep in workspace
await removeMemberFromGroup('7d3e5712-a873-43a8-a4b5-2ab138a9e2ea', NMID);
await removeMemberFromGroup('9e7b05bc-e9e6-4b7a-8246-f8b1af875ea2', NMID);
}
} else {
console.log(RED_COLOR, `Could not find ${memberName} <${email}> (${NMID})`);
}
Expand Down Expand Up @@ -101,7 +111,7 @@ async function removeMember(user) {
console.log(DIV);

for (const user of users) {
await removeMember(user);
await removeMember(user, argv.complete);
console.log(DIV);
}

Expand Down
10 changes: 5 additions & 5 deletions examples/nm/data/groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@
{
"displayName": "Formula Fundamentals 2.0",
"id": "70158620-4985-4b86-b08e-95657b6d2edf",
"memberCount": 85
"memberCount": 95
},
{
"displayName": "Notion Mastery",
"id": "7d3e5712-a873-43a8-a4b5-2ab138a9e2ea",
"memberCount": 602
"memberCount": 565
},
{
"displayName": "Notion Mastery Alumni",
"id": "922f01d5-b5e4-4f13-9be7-411242a2c68b",
"memberCount": 1169
"memberCount": 1168
},
{
"displayName": "Notion Mastery Membership",
"id": "9e7b05bc-e9e6-4b7a-8246-f8b1af875ea2",
"memberCount": 199
"memberCount": 220
},
{
"displayName": "Team",
"id": "6b4b5525-5248-4bee-9d4a-05d5114b58b9",
"memberCount": 4
}
]
]

0 comments on commit 8fd14ab

Please sign in to comment.