From 903c26dd4f8dbbe68a6ffc638f629ba91f01d1bf Mon Sep 17 00:00:00 2001 From: morgan Date: Fri, 4 Aug 2023 10:25:27 +0200 Subject: [PATCH] Fix de la requete avec codeDepartement et ajout de la date d'update --- src/tasks/stats/cras/crasByDepartements/index.js | 2 ++ .../cras/crasByDepartements/tasks/insertStatsOutilPrefet.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tasks/stats/cras/crasByDepartements/index.js b/src/tasks/stats/cras/crasByDepartements/index.js index dd18340..0876ba6 100644 --- a/src/tasks/stats/cras/crasByDepartements/index.js +++ b/src/tasks/stats/cras/crasByDepartements/index.js @@ -31,6 +31,7 @@ const findAndInsertStats = async (dbDatalake, query, departement) => { 'repartition_statuts': statutsParDepartement, 'repartition_thematiques': themesParDepartement.themes, 'repartition_sous_thematiques': themesParDepartement.sousThemes, + 'updatedAt': new Date(), }; await statsAlltasks.insertStatsOutilPrefet(dbDatalake)(statsOutilPrefet); @@ -58,6 +59,7 @@ execute(__filename, async ({ logger, dbDatalake }) => { //Lorsque les codeCommune seront importer => 'cra.codeCommune': { $regex: new RegExp(regex) }, 'cra.codePostal': { $regex: new RegExp(regex) } }; + await findAndInsertStats(dbDatalake, query, departement); resolve(); })); diff --git a/src/tasks/stats/cras/crasByDepartements/tasks/insertStatsOutilPrefet.js b/src/tasks/stats/cras/crasByDepartements/tasks/insertStatsOutilPrefet.js index e9032c7..e2cdee2 100644 --- a/src/tasks/stats/cras/crasByDepartements/tasks/insertStatsOutilPrefet.js +++ b/src/tasks/stats/cras/crasByDepartements/tasks/insertStatsOutilPrefet.js @@ -1,6 +1,6 @@ const insertStatsOutilPrefet = dbDatalake => async statsOutilPrefet => await dbDatalake.collection('stats_departements_cras_details').replaceOne( - { num_dep: statsOutilPrefet.num_dep }, + { codeDepartement: statsOutilPrefet.num_dep }, statsOutilPrefet, { upsert: true } );