@@ -115,7 +115,6 @@ export class BackendsService extends AbstractQueueProcessor {
115115 } ) ;
116116
117117 this . queueEvents . on ( 'completed' , async ( payload ) => {
118-
119118 const result = < WorkerResultInterface > ( < unknown > payload . returnvalue ) ;
120119
121120 if ( result ?. jobName === ActionType . DUMP_PACKAGE_CONFIG ) {
@@ -127,10 +126,8 @@ export class BackendsService extends AbstractQueueProcessor {
127126 }
128127 const disableLogs = result ?. options ?. disableLogs === true ;
129128 let jState = JobState . COMPLETED ;
130- let iState = IdentityState . SYNCED ;
131129 if ( result . status !== 0 ) {
132130 jState = JobState . FAILED ;
133- iState = IdentityState . ON_ERROR ;
134131 }
135132 const completedJob = await this . jobsService . model . findOneAndUpdate < Jobs > (
136133 { jobId : payload . jobId } ,
@@ -143,13 +140,13 @@ export class BackendsService extends AbstractQueueProcessor {
143140 } ,
144141 { upsert : true , new : true } ,
145142 ) ;
146- let myState = result . jobName === ActionType . IDENTITY_DELETE ? IdentityState . DONT_SYNC : IdentityState . SYNCED
143+ let myState = result . jobName === ActionType . IDENTITY_DELETE ? IdentityState . DONT_SYNC : IdentityState . SYNCED ;
147144 if ( jState === JobState . COMPLETED ) {
148145 this . logger . log ( `Job completed... Syncing [${ payload . jobId } ]` ) ;
149146 } else {
150147 this . logger . error ( `Job FAILED... Syncing [${ payload . jobId } ]` ) ;
151148 this . logger . error ( `Set State on error [${ payload . jobId } ]` ) ;
152- myState = IdentityState . ON_ERROR
149+ myState = IdentityState . ON_ERROR ;
153150 }
154151 await this . identitiesService . model . findByIdAndUpdate ( completedJob ?. concernedTo ?. id , {
155152 $set : {
@@ -158,7 +155,6 @@ export class BackendsService extends AbstractQueueProcessor {
158155 deletedFlag : result . jobName === ActionType . IDENTITY_DELETE ,
159156 } ,
160157 } ) ;
161-
162158 } ) ;
163159 }
164160
@@ -270,9 +266,10 @@ export class BackendsService extends AbstractQueueProcessor {
270266
271267 for ( const item of payload ) {
272268 const before = typeof item === 'string' ? undefined : item . before ;
273- const identityId = typeof item === 'string' ? item : ( item . after ?. _id ?. toString ( ) || item . id ) ;
269+ const identityId = typeof item === 'string' ? item : item . after ?. _id ?. toString ( ) || item . id ;
274270 if ( ! identityId ) throw new BadRequestException ( 'Missing identity id for lifecycle change' ) ;
275- const identity = ( typeof item === 'string' || ! item . after ) ? await this . identitiesService . findById < any > ( identityId ) : item . after ;
271+ const identity =
272+ typeof item === 'string' || ! item . after ? await this . identitiesService . findById < any > ( identityId ) : item . after ;
276273 // cas des fusion l employeeNumber doit etre celui de l identite primaire
277274 if ( identity . primaryEmployeeNumber !== null && identity . primaryEmployeeNumber !== '' ) {
278275 identity . inetOrgPerson . employeeNumber = identity . primaryEmployeeNumber ;
@@ -293,11 +290,16 @@ export class BackendsService extends AbstractQueueProcessor {
293290
294291 const result = { } ;
295292 for ( const identity of identities ) {
296- const [ executedJob ] = await this . executeJob ( identity . action , identity . identity . _id , { before : identity . before , after : identity . identity } , {
297- ...options ,
298- updateStatus : true ,
299- task : task . _id as unknown as Types . ObjectId ,
300- } ) ;
293+ const [ executedJob ] = await this . executeJob (
294+ identity . action ,
295+ identity . identity . _id ,
296+ { before : identity . before , after : identity . identity } ,
297+ {
298+ ...options ,
299+ updateStatus : true ,
300+ task : task . _id as unknown as Types . ObjectId ,
301+ } ,
302+ ) ;
301303 result [ identity . identity . _id ] = executedJob ;
302304 }
303305 return result ;
@@ -341,7 +343,7 @@ export class BackendsService extends AbstractQueueProcessor {
341343
342344 const result = { } ;
343345 for ( const identity of identities ) {
344- const [ executedJob , res ] = await this . executeJob ( identity . action , identity . identity . _id , identity . identity , {
346+ const [ executedJob ] = await this . executeJob ( identity . action , identity . identity . _id , identity . identity , {
345347 ...options ,
346348 updateStatus : true ,
347349 switchToProcessing : false ,
@@ -369,7 +371,7 @@ export class BackendsService extends AbstractQueueProcessor {
369371 message : `Identity ${ key } not found` ,
370372 } ) ;
371373 }
372-
374+
373375 const targetState = identity . lastBackendSync ? IdentityState . TO_SYNC : IdentityState . TO_CREATE ;
374376 await this . identitiesService . model . findByIdAndUpdate ( key , {
375377 $set : {
@@ -494,7 +496,7 @@ export class BackendsService extends AbstractQueueProcessor {
494496 public async executeJob (
495497 actionType : ActionType ,
496498 concernedTo ?: Types . ObjectId ,
497- // eslint-disable-next-line @typescript-eslint/no-unused-vars
499+
498500 payload ?: Record < string | number , any > ,
499501 options ?: ExecuteJobOptions ,
500502 ) : Promise < [ Jobs , any ] > {
@@ -507,7 +509,7 @@ export class BackendsService extends AbstractQueueProcessor {
507509 } ,
508510 {
509511 ...options ?. job ,
510- jobId : ( new Types . ObjectId ( ) ) . toHexString ( ) ,
512+ jobId : new Types . ObjectId ( ) . toHexString ( ) ,
511513 attempts : 1 ,
512514 } ,
513515 options ?. async ,
@@ -528,7 +530,8 @@ export class BackendsService extends AbstractQueueProcessor {
528530 let jobStore : Document < Jobs > = null ;
529531 const disableLogs = options ?. disableLogs === true ;
530532 if ( ! disableLogs || ! ! concernedTo ) {
531- const identity = ! disableLogs && concernedTo ? await this . identitiesService . findById < Identities > ( concernedTo ) : null ;
533+ const identity =
534+ ! disableLogs && concernedTo ? await this . identitiesService . findById < Identities > ( concernedTo ) : null ;
532535 jobStore = await this . jobsService . create < Jobs > ( {
533536 jobId : job . id ,
534537 action : actionType ,
@@ -594,8 +597,7 @@ export class BackendsService extends AbstractQueueProcessor {
594597 return [ jobStoreUpdated as unknown as Jobs , response ] ;
595598 } catch ( err ) {
596599 error = err instanceof Error ? err : new Error ( String ( err ) ) ;
597- const isDiscardedHealthCheck =
598- options ?. disableLogs && options ?. timeoutDiscard && error . name === 'TimeoutError' ;
600+ const isDiscardedHealthCheck = options ?. disableLogs && options ?. timeoutDiscard && error . name === 'TimeoutError' ;
599601
600602 if ( isDiscardedHealthCheck ) {
601603 const waitedMs = options . syncTimeout || DEFAULT_SYNC_TIMEOUT ;
0 commit comments