File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -135,11 +135,17 @@ export const checkUploadsStatus = async (uploadsId: string[]) => {
135
135
136
136
return Promise . all (
137
137
uploads
138
- . filter ( ( upload ) =>
139
- upload . products . every ( ( product ) => product . status === Status . Done || product . status === Status . Error ) ,
138
+ . filter (
139
+ ( upload ) =>
140
+ upload . products . every ( ( product ) => product . status === Status . Done || product . status === Status . Error ) &&
141
+ upload . reUploadProducts . every (
142
+ ( product ) => product . product . status === Status . Done || product . product . status === Status . Error ,
143
+ ) ,
140
144
)
141
145
. map ( async ( upload ) => {
142
- const allDone = upload . products . every ( ( product ) => product . status === Status . Done )
146
+ const allDone =
147
+ upload . products . every ( ( product ) => product . status === Status . Done ) &&
148
+ upload . reUploadProducts . every ( ( product ) => product . product . status === Status . Done )
143
149
if ( allDone ) {
144
150
return completeUpload ( upload )
145
151
} else {
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ const generate = (name: string, length?: string) => {
44
44
countryMaking : faker . helpers . arrayElement ( Object . keys ( countries ) ) ,
45
45
countrySpinning : faker . helpers . arrayElement ( Object . keys ( countries ) ) ,
46
46
impressionMapping : faker . helpers . arrayElement ( [ "" , ...Object . keys ( impressionMapping ) ] ) ,
47
- impressionPercentage : faker . number . float ( { min : 0 , max : 1 } ) ,
47
+ impressionPercentage : faker . number . float ( { min : 0 , max : 0.8 } ) ,
48
48
mass : faker . number . float ( { min : 0.01 } ) ,
49
49
price : faker . number . float ( { min : 1 , max : 1000 } ) ,
50
50
airTransportRatio : faker . number . float ( { min : 0 , max : 1 } ) ,
Original file line number Diff line number Diff line change 1
1
import chardet from "chardet"
2
2
import { parseCSV } from "../csv/parse"
3
3
import { createProducts } from "../../db/product"
4
- import { completeUpload , failUpload } from "../../services/upload"
5
- import { getFirstFileUpload , updateUploadToPending } from "../../db/upload"
4
+ import { failUpload } from "../../services/upload"
5
+ import { checkUploadsStatus , getFirstFileUpload , updateUploadToPending } from "../../db/upload"
6
6
import { downloadFileFromS3 } from "../s3/bucket"
7
7
import { decryptAndDezipFile } from "../encryption/encryption"
8
8
@@ -39,7 +39,7 @@ export const processUploadsToQueue = async () => {
39
39
const csvData = await parseCSV ( buffer , encoding , upload )
40
40
const numberOfCreatedProduct = await createProducts ( csvData )
41
41
if ( numberOfCreatedProduct === 0 ) {
42
- await completeUpload ( upload )
42
+ await checkUploadsStatus ( [ upload . id ] )
43
43
}
44
44
console . log ( `Upload processed, ${ csvData . products . length } products, ${ numberOfCreatedProduct } created` )
45
45
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments