@@ -4,9 +4,9 @@ import subMinutes from 'date-fns/subMinutes';
4
4
import * as t from 'io-ts' ;
5
5
import _ from 'lodash' ;
6
6
import { MongoClient } from 'mongodb' ;
7
- import { Logger , trexLogger } from '../logger' ;
8
- import { sleep } from '../utils/promise.utils' ;
9
- import type * as mongo3 from './mongo.provider' ;
7
+ import { Logger , trexLogger } from '../../ logger' ;
8
+ import { sleep } from '../../ utils/promise.utils' ;
9
+ import type * as mongo3 from '.. /mongo.provider' ;
10
10
11
11
/**
12
12
* The parser configuration
@@ -491,7 +491,8 @@ export const parseContributions =
491
491
ctx . log . debug ( 'Parsed %O' , result ) ;
492
492
const oldMetadata = await ctx . getMetadata ( entry ) ;
493
493
const metadata = ctx . buildMetadata ( result , oldMetadata ) ;
494
- ctx . log . debug ( 'Metadata %O' , metadata ) ;
494
+
495
+ // ctx.log.debug('Metadata %O', metadata);
495
496
496
497
if ( metadata ) {
497
498
const m = await ctx . saveResults ( result . source , metadata ) ;
@@ -513,6 +514,15 @@ export const parseContributions =
513
514
return results ;
514
515
} ;
515
516
517
+ const getMemoryUsed = ( ) : NodeJS . MemoryUsage => {
518
+ const used = process . memoryUsage ( ) ;
519
+ const memoryLog : any = { } ;
520
+ for ( const key in used ) {
521
+ memoryLog [ key ] = Math . round ( ( ( used as any ) [ key ] / 1024 / 1024 ) * 100 ) / 100 ;
522
+ }
523
+ return memoryLog ;
524
+ } ;
525
+
516
526
/* yes a better way might exist */
517
527
let previousFrequency = 0 ;
518
528
@@ -552,6 +562,8 @@ export const executionLoop =
552
562
stop ,
553
563
processedCounter
554
564
) ;
565
+ ctx . log . info ( 'Memory usage %O (MB)' , getMemoryUsed ( ) ) ;
566
+
555
567
let htmlFilter : Record < string , any > = {
556
568
savingTime : {
557
569
$gt : lastExecution ,
@@ -663,14 +675,14 @@ export const getSuccessfulOutput = <
663
675
) : any => {
664
676
return output . reduce ( ( acc , { source, metadata, failures, log, count } ) => {
665
677
const index = getEntryId ( source ) . substring ( 0 , 6 ) ;
678
+ const { id, nature } = ( metadata as any ) ?? { } ;
679
+ const n : any = nature ;
666
680
return {
667
681
...acc ,
668
682
[ index ] : {
669
683
...log ,
670
- // log: JSON.stringify(log),
671
- // findings: markOutputField(findings),
672
- // metadata: (metadata as any)?.id ?? null,
673
- ...metadata ,
684
+ id,
685
+ nature : n ?. nature ?. type ?? n ?. type ,
674
686
failures : JSON . stringify (
675
687
Object . entries ( failures ) . map ( ( [ key , value ] ) => ( {
676
688
[ key ] : value . message ,
0 commit comments