@@ -105,39 +105,20 @@ export class TemplateStorageHelper {
105105 )
106106 ) ;
107107
108- const owners = keys
109- . map ( ( key ) => key . owner )
110- . filter ( ( owner , i , list ) => list . indexOf ( owner ) === i ) ;
108+ const files = keys . flatMap ( ( key ) => [
109+ `pdf-template/${ key . owner } /${ key . id } .pdf` ,
110+ `test-data/${ key . owner } /${ key . id } .csv` ,
111+ ] ) ;
111112
112- const files = await Promise . all (
113- owners . map ( async ( owner ) => {
114- const pdfs = await this . s3 . send (
115- new ListObjectsV2Command ( {
116- Bucket : process . env . TEMPLATES_INTERNAL_BUCKET_NAME ,
117- Prefix : `pdf-template/${ owner } ` ,
118- } )
119- ) ;
120-
121- const csvs = await this . s3 . send (
122- new ListObjectsV2Command ( {
123- Bucket : process . env . TEMPLATES_INTERNAL_BUCKET_NAME ,
124- Prefix : `test-data/${ owner } ` ,
125- } )
126- ) ;
127-
128- return [ ...( pdfs . Contents || [ ] ) , ...( csvs . Contents || [ ] ) ] ;
129- } )
130- ) ;
131-
132- const s3Chunks = TemplateStorageHelper . chunk ( files . flat ( ) , 1000 ) ;
113+ const s3Chunks = TemplateStorageHelper . chunk ( files , 1000 ) ;
133114
134115 await Promise . all (
135116 s3Chunks . map ( ( chunk ) =>
136117 this . s3 . send (
137118 new DeleteObjectsCommand ( {
138119 Bucket : process . env . TEMPLATES_INTERNAL_BUCKET_NAME ,
139120 Delete : {
140- Objects : chunk . map ( ( { Key } ) => ( { Key } ) ) ,
121+ Objects : chunk . map ( ( key ) => ( { Key : key } ) ) ,
141122 } ,
142123 } )
143124 )
0 commit comments