@@ -10,17 +10,24 @@ const { findAndRemoveCircleMember } = require('../shared/circle');
1010const { findAndTagConvertkitSubscriber } = require ( '../shared/convertkit' ) ;
1111const { 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
1926const RPS = 1 ;
2027const limit = RateLimit ( RPS ) ;
2128const 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
0 commit comments