@@ -86,11 +86,10 @@ export async function cleanWorkspace (
86
86
opt : { recruit : boolean , tracker : boolean , removedTx : boolean }
87
87
) : Promise < void > {
88
88
const connection = ( await connect ( transactorUrl , workspaceId , undefined , {
89
- mode : 'backup' ,
90
- model : 'upgrade'
89
+ mode : 'backup'
91
90
} ) ) as unknown as CoreClient & BackupClient
92
91
try {
93
- const ops = new TxOperations ( connection , core . account . System )
92
+ const ops = new TxOperations ( connection , core . account . System , workspaceId )
94
93
95
94
const hierarchy = ops . getHierarchy ( )
96
95
@@ -164,6 +163,7 @@ export async function cleanWorkspace (
164
163
client . close ( )
165
164
}
166
165
} catch ( err : any ) {
166
+ // TODO: Add force-close
167
167
console . trace ( err )
168
168
} finally {
169
169
await connection . close ( )
@@ -232,8 +232,7 @@ export async function cleanRemovedTransactions (workspaceId: WorkspaceUuid, tran
232
232
233
233
export async function optimizeModel ( workspaceId : WorkspaceUuid , transactorUrl : string ) : Promise < void > {
234
234
const connection = ( await connect ( transactorUrl , workspaceId , undefined , {
235
- mode : 'backup' ,
236
- model : 'upgrade'
235
+ mode : 'backup'
237
236
} ) ) as unknown as CoreClient & BackupClient
238
237
try {
239
238
let count = 0
@@ -298,6 +297,8 @@ export async function optimizeModel (workspaceId: WorkspaceUuid, transactorUrl:
298
297
} catch ( err : any ) {
299
298
console . trace ( err )
300
299
} finally {
300
+ // TODO: Add force-close
301
+ await connection . sendForceClose ( )
301
302
await connection . close ( )
302
303
}
303
304
}
@@ -307,7 +308,7 @@ export async function cleanArchivedSpaces (workspaceId: WorkspaceUuid, transacto
307
308
} ) ) as unknown as CoreClient & BackupClient
308
309
try {
309
310
const count = 0
310
- const ops = new TxOperations ( connection , core . account . System )
311
+ const ops = new TxOperations ( connection , core . account . System , workspaceId )
311
312
while ( true ) {
312
313
const spaces = await connection . findAll ( core . class . Space , { archived : true } , { limit : 1000 } )
313
314
if ( spaces . length === 0 ) {
@@ -475,7 +476,7 @@ export async function fixSkills (
475
476
// fix skills with + and -
476
477
if ( step === '3' ) {
477
478
console . log ( 'STEP 3' )
478
- const ops = new TxOperations ( connection , core . account . System )
479
+ const ops = new TxOperations ( connection , core . account . System , workspaceId )
479
480
const regex = / \S + (?: [ - + ] \S + ) + / g
480
481
const tagsToClean = ( await connection . findAll ( tags . class . TagElement , {
481
482
category : {
@@ -532,7 +533,7 @@ export async function fixSkills (
532
533
}
533
534
} ) ) as TagElement [ ]
534
535
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 )
536
537
const tagsToClean = ( await connection . findAll ( tags . class . TagElement , {
537
538
category : {
538
539
$in : [ 'recruit:category:Other' , 'document:category:Other' , 'tracker:category:Other' ] as Ref < TagCategory > [ ]
@@ -669,8 +670,7 @@ export async function restoreRecruitingTaskTypes (
669
670
transactorUrl : string
670
671
) : Promise < void > {
671
672
const connection = ( await connect ( transactorUrl , workspaceId , undefined , {
672
- mode : 'backup' ,
673
- model : 'upgrade'
673
+ mode : 'backup'
674
674
} ) ) as unknown as CoreClient & BackupClient
675
675
const client = getMongoClient ( mongoUrl )
676
676
try {
@@ -772,6 +772,7 @@ export async function restoreRecruitingTaskTypes (
772
772
statusCategories . sort ( compareCategories )
773
773
774
774
const createTxNew : TxCreateDoc < TaskType > = {
775
+ _uuid : workspaceId ,
775
776
_id : generateId ( ) ,
776
777
_class : core . class . TxCreateDoc ,
777
778
space : core . space . Tx ,
@@ -822,7 +823,9 @@ export async function restoreRecruitingTaskTypes (
822
823
} catch ( err : any ) {
823
824
console . trace ( err )
824
825
} finally {
826
+ // TODO: Add force-close
825
827
client . close ( )
828
+ await connection . sendForceClose ( )
826
829
await connection . close ( )
827
830
}
828
831
}
@@ -833,8 +836,7 @@ export async function restoreHrTaskTypesFromUpdates (
833
836
transactorUrl : string
834
837
) : Promise < void > {
835
838
const connection = ( await connect ( transactorUrl , workspaceId , undefined , {
836
- mode : 'backup' ,
837
- model : 'upgrade'
839
+ mode : 'backup'
838
840
} ) ) as unknown as CoreClient & BackupClient
839
841
const client = getMongoClient ( mongoUrl )
840
842
try {
@@ -927,6 +929,7 @@ export async function restoreHrTaskTypesFromUpdates (
927
929
const ofClassClass = hierarchy . getClass ( recruit . class . Applicant )
928
930
929
931
await db . collection < TxCreateDoc < Doc > > ( DOMAIN_TX ) . insertOne ( {
932
+ _uuid : workspaceId ,
930
933
_id : generateId ( ) ,
931
934
_class : core . class . TxCreateDoc ,
932
935
space : core . space . Tx ,
@@ -946,6 +949,7 @@ export async function restoreHrTaskTypesFromUpdates (
946
949
} )
947
950
948
951
createTaskTypeTx = {
952
+ _uuid : workspaceId ,
949
953
_id : generateId ( ) ,
950
954
_class : core . class . TxCreateDoc ,
951
955
space : core . space . Tx ,
@@ -980,6 +984,7 @@ export async function restoreHrTaskTypesFromUpdates (
980
984
const ofClassClass = hierarchy . getClass ( recruit . class . Vacancy )
981
985
982
986
await db . collection < TxCreateDoc < Doc > > ( DOMAIN_TX ) . insertOne ( {
987
+ _uuid : workspaceId ,
983
988
_id : generateId ( ) ,
984
989
_class : core . class . TxCreateDoc ,
985
990
space : core . space . Tx ,
@@ -999,6 +1004,7 @@ export async function restoreHrTaskTypesFromUpdates (
999
1004
} )
1000
1005
1001
1006
const createProjectTypeTx : TxCreateDoc < ProjectType > = {
1007
+ _uuid : workspaceId ,
1002
1008
_id : generateId ( ) ,
1003
1009
_class : core . class . TxCreateDoc ,
1004
1010
space : core . space . Tx ,
@@ -1031,6 +1037,7 @@ export async function restoreHrTaskTypesFromUpdates (
1031
1037
console . trace ( err )
1032
1038
} finally {
1033
1039
client . close ( )
1040
+ await connection . sendForceClose ( )
1034
1041
await connection . close ( )
1035
1042
}
1036
1043
}
0 commit comments