11import { DatabaseController } from '../../../lib/db/controller' ;
22import { Worker } from '../../../lib/worker' ;
33import * as pkg from '../package.json' ;
4- import asyncForEach from '../../../lib/utils/asyncForEach' ;
54import { Collection , Db , GridFSBucket , ObjectId , ObjectID } from 'mongodb' ;
65import axios from 'axios' ;
76import { ReleaseFileData , ReleaseRecord , ReportData , ReportDataByProject } from './types' ;
@@ -85,10 +84,13 @@ export default class ArchiverWorker extends Worker {
8584
8685 this . logger . info ( `Start archiving at ${ startDate } ` ) ;
8786
88- const projects = await this . projectCollection . find ( { } ) . toArray ( ) ;
87+ const projects = await this . projectCollection . find ( { } ) . project ( {
88+ _id : 1 ,
89+ name : 1
90+ } ) ;
8991 const projectsData : ReportDataByProject [ ] = [ ] ;
9092
91- await asyncForEach ( projects , async ( project ) => {
93+ for await ( const project of projects ) {
9294 const archivedEventsCount = await this . archiveProjectEvents ( project ) ;
9395
9496 const removedReleasesCount = await this . removeOldReleases ( project ) ;
@@ -98,7 +100,7 @@ export default class ArchiverWorker extends Worker {
98100 archivedEventsCount,
99101 removedReleasesCount,
100102 } ) ;
101- } ) ;
103+ }
102104
103105 const finishDate = new Date ( ) ;
104106 const dbSizeOnFinish = ( await this . eventsDbConnection . stats ( ) ) . dataSize ;
@@ -347,9 +349,9 @@ export default class ArchiverWorker extends Worker {
347349 } ) ;
348350
349351 this . logger . info ( 'Report notification response:' , {
350- status : response . status ,
351- statusText : response . statusText ,
352- data : response . data
352+ status : response ? .status ,
353+ statusText : response ? .statusText ,
354+ data : response ? .data
353355 } ) ;
354356 }
355357
0 commit comments