Skip to content

Commit 8fd14ab

Browse files
committed
Adds --complete option to removal script
1 parent ce1c604 commit 8fd14ab

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

examples/nm/bulk-member-remove.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@ const { findAndRemoveCircleMember } = require('../shared/circle');
1010
const { findAndTagConvertkitSubscriber } = require('../shared/convertkit');
1111
const { RED_COLOR, yargs } = require('../shared/scim');
1212

13-
const argv = yargs.option('i', {
14-
alias: 'id',
15-
type: 'string',
16-
describe: 'The ID of the Student in the Student database',
17-
}).argv;
13+
const argv = yargs
14+
.option('i', {
15+
alias: 'id',
16+
type: 'string',
17+
describe: 'The ID of the Student in the Student database',
18+
})
19+
.option('c', {
20+
alias: 'complete',
21+
type: 'boolean',
22+
describe: 'Totally remove the Student from the NOTION MASTERY workspace?',
23+
default: false,
24+
}).argv;
1825

1926
const RPS = 1;
2027
const limit = RateLimit(RPS);
2128
const DIV = '~~~~~~~~~~';
2229

23-
async function removeMember(user) {
30+
async function removeMember(user, complete = false) {
2431
await limit();
2532

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

3643
if (member) {
37-
// Remove entirely...
38-
// await removeMemberFromWorkspace(NMID);
39-
40-
// Remove from Notion Mastery group but keep in workspace
41-
await removeMemberFromGroup('7d3e5712-a873-43a8-a4b5-2ab138a9e2ea', NMID);
44+
if (complete) {
45+
// Remove entirely...
46+
await removeMemberFromWorkspace(NMID);
47+
} else {
48+
// Remove from Notion Mastery groups but keep in workspace
49+
await removeMemberFromGroup('7d3e5712-a873-43a8-a4b5-2ab138a9e2ea', NMID);
50+
await removeMemberFromGroup('9e7b05bc-e9e6-4b7a-8246-f8b1af875ea2', NMID);
51+
}
4252
} else {
4353
console.log(RED_COLOR, `Could not find ${memberName} <${email}> (${NMID})`);
4454
}
@@ -101,7 +111,7 @@ async function removeMember(user) {
101111
console.log(DIV);
102112

103113
for (const user of users) {
104-
await removeMember(user);
114+
await removeMember(user, argv.complete);
105115
console.log(DIV);
106116
}
107117

examples/nm/data/groups.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,26 @@
2222
{
2323
"displayName": "Formula Fundamentals 2.0",
2424
"id": "70158620-4985-4b86-b08e-95657b6d2edf",
25-
"memberCount": 85
25+
"memberCount": 95
2626
},
2727
{
2828
"displayName": "Notion Mastery",
2929
"id": "7d3e5712-a873-43a8-a4b5-2ab138a9e2ea",
30-
"memberCount": 602
30+
"memberCount": 565
3131
},
3232
{
3333
"displayName": "Notion Mastery Alumni",
3434
"id": "922f01d5-b5e4-4f13-9be7-411242a2c68b",
35-
"memberCount": 1169
35+
"memberCount": 1168
3636
},
3737
{
3838
"displayName": "Notion Mastery Membership",
3939
"id": "9e7b05bc-e9e6-4b7a-8246-f8b1af875ea2",
40-
"memberCount": 199
40+
"memberCount": 220
4141
},
4242
{
4343
"displayName": "Team",
4444
"id": "6b4b5525-5248-4bee-9d4a-05d5114b58b9",
4545
"memberCount": 4
4646
}
47-
]
47+
]

0 commit comments

Comments
 (0)