@@ -86,11 +86,10 @@ export async function cleanWorkspace (
8686  opt : {  recruit : boolean ,  tracker : boolean ,  removedTx : boolean  } 
8787) : Promise < void >  { 
8888  const  connection  =  ( await  connect ( transactorUrl ,  workspaceId ,  undefined ,  { 
89-     mode : 'backup' , 
90-     model : 'upgrade' 
89+     mode : 'backup' 
9190  } ) )  as  unknown  as  CoreClient  &  BackupClient 
9291  try  { 
93-     const  ops  =  new  TxOperations ( connection ,  core . account . System ) 
92+     const  ops  =  new  TxOperations ( connection ,  core . account . System ,   workspaceId ) 
9493
9594    const  hierarchy  =  ops . getHierarchy ( ) 
9695
@@ -164,6 +163,7 @@ export async function cleanWorkspace (
164163      client . close ( ) 
165164    } 
166165  }  catch  ( err : any )  { 
166+     // TODO: Add force-close 
167167    console . trace ( err ) 
168168  }  finally  { 
169169    await  connection . close ( ) 
@@ -232,8 +232,7 @@ export async function cleanRemovedTransactions (workspaceId: WorkspaceUuid, tran
232232
233233export  async  function  optimizeModel  ( workspaceId : WorkspaceUuid ,  transactorUrl : string ) : Promise < void >  { 
234234  const  connection  =  ( await  connect ( transactorUrl ,  workspaceId ,  undefined ,  { 
235-     mode : 'backup' , 
236-     model : 'upgrade' 
235+     mode : 'backup' 
237236  } ) )  as  unknown  as  CoreClient  &  BackupClient 
238237  try  { 
239238    let  count  =  0 
@@ -298,6 +297,8 @@ export async function optimizeModel (workspaceId: WorkspaceUuid, transactorUrl:
298297  }  catch  ( err : any )  { 
299298    console . trace ( err ) 
300299  }  finally  { 
300+     // TODO: Add force-close 
301+     await  connection . sendForceClose ( ) 
301302    await  connection . close ( ) 
302303  } 
303304} 
@@ -307,7 +308,7 @@ export async function cleanArchivedSpaces (workspaceId: WorkspaceUuid, transacto
307308  } ) )  as  unknown  as  CoreClient  &  BackupClient 
308309  try  { 
309310    const  count  =  0 
310-     const  ops  =  new  TxOperations ( connection ,  core . account . System ) 
311+     const  ops  =  new  TxOperations ( connection ,  core . account . System ,   workspaceId ) 
311312    while  ( true )  { 
312313      const  spaces  =  await  connection . findAll ( core . class . Space ,  {  archived : true  } ,  {  limit : 1000  } ) 
313314      if  ( spaces . length  ===  0 )  { 
@@ -475,7 +476,7 @@ export async function fixSkills (
475476    // fix skills with + and - 
476477    if  ( step  ===  '3' )  { 
477478      console . log ( 'STEP 3' ) 
478-       const  ops  =  new  TxOperations ( connection ,  core . account . System ) 
479+       const  ops  =  new  TxOperations ( connection ,  core . account . System ,   workspaceId ) 
479480      const  regex  =  / \S + (?: [ - + ] \S + ) + / g
480481      const  tagsToClean  =  ( await  connection . findAll ( tags . class . TagElement ,  { 
481482        category : { 
@@ -532,7 +533,7 @@ export async function fixSkills (
532533        } 
533534      } ) )  as  TagElement [ ] 
534535      goodTags  =  goodTags . sort ( ( a ,  b )  =>  b . title . length  -  a . title . length ) . filter ( ( t )  =>  t . title . length  >  2 ) 
535-       const  ops  =  new  TxOperations ( connection ,  core . account . System ) 
536+       const  ops  =  new  TxOperations ( connection ,  core . account . System ,   workspaceId ) 
536537      const  tagsToClean  =  ( await  connection . findAll ( tags . class . TagElement ,  { 
537538        category : { 
538539          $in : [ 'recruit:category:Other' ,  'document:category:Other' ,  'tracker:category:Other' ]  as  Ref < TagCategory > [ ] 
@@ -669,8 +670,7 @@ export async function restoreRecruitingTaskTypes (
669670  transactorUrl : string 
670671) : Promise < void >  { 
671672  const  connection  =  ( await  connect ( transactorUrl ,  workspaceId ,  undefined ,  { 
672-     mode : 'backup' , 
673-     model : 'upgrade' 
673+     mode : 'backup' 
674674  } ) )  as  unknown  as  CoreClient  &  BackupClient 
675675  const  client  =  getMongoClient ( mongoUrl ) 
676676  try  { 
@@ -772,6 +772,7 @@ export async function restoreRecruitingTaskTypes (
772772        statusCategories . sort ( compareCategories ) 
773773
774774        const  createTxNew : TxCreateDoc < TaskType >  =  { 
775+           _uuid : workspaceId , 
775776          _id : generateId ( ) , 
776777          _class : core . class . TxCreateDoc , 
777778          space : core . space . Tx , 
@@ -822,7 +823,9 @@ export async function restoreRecruitingTaskTypes (
822823  }  catch  ( err : any )  { 
823824    console . trace ( err ) 
824825  }  finally  { 
826+     // TODO: Add force-close 
825827    client . close ( ) 
828+     await  connection . sendForceClose ( ) 
826829    await  connection . close ( ) 
827830  } 
828831} 
@@ -833,8 +836,7 @@ export async function restoreHrTaskTypesFromUpdates (
833836  transactorUrl : string 
834837) : Promise < void >  { 
835838  const  connection  =  ( await  connect ( transactorUrl ,  workspaceId ,  undefined ,  { 
836-     mode : 'backup' , 
837-     model : 'upgrade' 
839+     mode : 'backup' 
838840  } ) )  as  unknown  as  CoreClient  &  BackupClient 
839841  const  client  =  getMongoClient ( mongoUrl ) 
840842  try  { 
@@ -927,6 +929,7 @@ export async function restoreHrTaskTypesFromUpdates (
927929        const  ofClassClass  =  hierarchy . getClass ( recruit . class . Applicant ) 
928930
929931        await  db . collection < TxCreateDoc < Doc > > ( DOMAIN_TX ) . insertOne ( { 
932+           _uuid : workspaceId , 
930933          _id : generateId ( ) , 
931934          _class : core . class . TxCreateDoc , 
932935          space : core . space . Tx , 
@@ -946,6 +949,7 @@ export async function restoreHrTaskTypesFromUpdates (
946949        } ) 
947950
948951        createTaskTypeTx  =  { 
952+           _uuid : workspaceId , 
949953          _id : generateId ( ) , 
950954          _class : core . class . TxCreateDoc , 
951955          space : core . space . Tx , 
@@ -980,6 +984,7 @@ export async function restoreHrTaskTypesFromUpdates (
980984      const  ofClassClass  =  hierarchy . getClass ( recruit . class . Vacancy ) 
981985
982986      await  db . collection < TxCreateDoc < Doc > > ( DOMAIN_TX ) . insertOne ( { 
987+         _uuid : workspaceId , 
983988        _id : generateId ( ) , 
984989        _class : core . class . TxCreateDoc , 
985990        space : core . space . Tx , 
@@ -999,6 +1004,7 @@ export async function restoreHrTaskTypesFromUpdates (
9991004      } ) 
10001005
10011006      const  createProjectTypeTx : TxCreateDoc < ProjectType >  =  { 
1007+         _uuid : workspaceId , 
10021008        _id : generateId ( ) , 
10031009        _class : core . class . TxCreateDoc , 
10041010        space : core . space . Tx , 
@@ -1031,6 +1037,7 @@ export async function restoreHrTaskTypesFromUpdates (
10311037    console . trace ( err ) 
10321038  }  finally  { 
10331039    client . close ( ) 
1040+     await  connection . sendForceClose ( ) 
10341041    await  connection . close ( ) 
10351042  } 
10361043} 
0 commit comments