From 8fd14ab34e6d0af2f280b6783ff3123e0c4b63fb Mon Sep 17 00:00:00 2001 From: Benjamin Borowski Date: Mon, 20 May 2024 17:30:57 -0700 Subject: [PATCH] Adds --complete option to removal script --- examples/nm/bulk-member-remove.js | 34 ++++++++++++++++++++----------- examples/nm/data/groups.json | 10 ++++----- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/examples/nm/bulk-member-remove.js b/examples/nm/bulk-member-remove.js index 7fc4fc9..3567027 100644 --- a/examples/nm/bulk-member-remove.js +++ b/examples/nm/bulk-member-remove.js @@ -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']; @@ -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})`); } @@ -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); } diff --git a/examples/nm/data/groups.json b/examples/nm/data/groups.json index c33ce5e..5ddc6a9 100644 --- a/examples/nm/data/groups.json +++ b/examples/nm/data/groups.json @@ -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 } -] \ No newline at end of file +]