Commit bf81ca7 1 parent 27b7c09 commit bf81ca7 Copy full SHA for bf81ca7
File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,13 @@ export default async function monitorSiren(job) {
21
21
22
22
const siretStockFromPaysage = await getSiretStockFromPaysage ( ) ;
23
23
24
- await new Promise ( ( resolve ) => setTimeout ( resolve , 10000 ) ) ;
24
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 100000 ) ) ;
25
25
26
26
const updatesInSirene = await fetchSireneUpdates (
27
27
lastSuccessfullExecutionDate ,
28
28
new Date ( ) . toISOString ( ) . split ( "T" ) ?. [ 0 ] ,
29
29
) ;
30
+ console . log ( updatesInSirene ?. length , updatesInSirene ) ;
30
31
31
32
const stockToBeUpdated = siretStockFromPaysage . filter ( ( { siret } ) =>
32
33
updatesInSirene . some ( ( update ) => update . siret === siret ) ,
@@ -42,7 +43,13 @@ export default async function monitorSiren(job) {
42
43
sireneData,
43
44
} ) ;
44
45
}
45
-
46
+ if ( stockUpdates . length === 0 ) {
47
+ return { status : "success" , lastExecution : now , updatesInSirene } ;
48
+ }
46
49
const ok = await db . collection ( "_siren" ) . insertMany ( stockUpdates ) ;
47
- return { status : ok ? "success" : "failed" , lastExecution : now } ;
50
+ return {
51
+ status : ok ? "success" : "failed" ,
52
+ lastExecution : now ,
53
+ updatesInSirene,
54
+ } ;
48
55
}
You can’t perform that action at this time.
0 commit comments