@@ -209,14 +209,17 @@ export default class DataSinkService extends LoggerBase {
209209
210210 await Promise . all ( promises )
211211
212- this . log . info ( `Prepared ${ prepared . length } in memory results stored ${ promises . length } in db!` )
212+ this . log . info (
213+ `[RESULTS] Prepared ${ prepared . length } in memory results stored ${ promises . length } in db!` ,
214+ )
213215
214216 return prepared
215217 }
216218
217219 public async processResults (
218220 batch : { resultId : string ; data : IResultData | undefined ; created : boolean } [ ] ,
219221 ) : Promise < void > {
222+ this . log . trace ( `[RESULTS] Processing ${ batch . length } results!` )
220223 const start = performance . now ( )
221224
222225 const results : IResultData [ ] = [ ]
@@ -233,6 +236,7 @@ export default class DataSinkService extends LoggerBase {
233236 }
234237
235238 if ( toLoadById . length > 0 ) {
239+ this . log . info ( `[RESULTS] Loading ${ toLoadById . length } results from db!` )
236240 const infos = await this . repo . getResultInfos ( toLoadById )
237241 results . push ( ...infos )
238242 }
@@ -269,10 +273,12 @@ export default class DataSinkService extends LoggerBase {
269273
270274 while ( toProcess . length > 0 && retry < 5 ) {
271275 if ( retry > 0 ) {
276+ this . log . trace ( `[RESULTS] Retrying but sleeping first...` )
272277 await timeout ( 100 )
273278 }
274279
275280 try {
281+ this . log . trace ( `[RESULTS] Processing ${ toProcess . length } activity results...` )
276282 const processResults = await service . processActivities (
277283 toProcess . map ( ( r ) => {
278284 return {
@@ -296,6 +302,10 @@ export default class DataSinkService extends LoggerBase {
296302 }
297303 }
298304
305+ this . log . trace (
306+ `[RESULTS] Processed ${ processResults . size } activity results! We have total of ${ resultMap . size } results for this batch and ${ toProcess . length } to retry.` ,
307+ )
308+
299309 // clear last error because we processed without unhandled error
300310 lastError = undefined
301311 } catch ( err ) {
@@ -310,6 +320,9 @@ export default class DataSinkService extends LoggerBase {
310320
311321 // if lastError is still set and we have some left to process, we set the error for them cuz they were retried but failed
312322 if ( lastError && toProcess . length > 0 ) {
323+ this . log . trace (
324+ `[RESULTS] Setting error for ${ toProcess . length } activity results because we hit a retry limit!` ,
325+ )
313326 for ( const leftToProcess of toProcess ) {
314327 resultMap . set ( leftToProcess . id , {
315328 success : false ,
@@ -331,15 +344,18 @@ export default class DataSinkService extends LoggerBase {
331344 const memberData = entry . data . data as IMemberData
332345
333346 await service . processMemberUpdate ( entry . integrationId , entry . platform , memberData )
347+ resultMap . set ( entry . id , { success : true } )
334348 } catch ( err ) {
335349 resultMap . set ( entry . id , { success : false , err } )
336350 }
337351 }
338352 } else {
339- this . log . error ( `Unknown result type: ${ type } !` )
353+ this . log . error ( `[RESULTS] Unknown result type: ${ type } !` )
340354 }
341355 }
342356
357+ this . log . trace ( `[RESULTS] Processing ${ resultMap . size } process results!` )
358+
343359 // handle results
344360 let errors = 0
345361 let successes = 0
@@ -371,10 +387,11 @@ export default class DataSinkService extends LoggerBase {
371387 }
372388
373389 if ( resultsToDelete . length > 0 ) {
390+ this . log . trace ( `[RESULTS] Deleting ${ resultsToDelete . length } results from db!` )
374391 await this . repo . deleteResults ( resultsToDelete )
375392 }
376393
377- this . log . info (
394+ this . log . trace (
378395 `Processed ${ successes } results successfully, ${ errors } with error, ${ deletions } were deleted from db!` ,
379396 )
380397
0 commit comments