From 9e1af437687d5d577ee986943142bc316a0e2a18 Mon Sep 17 00:00:00 2001 From: David Bruant Date: Wed, 12 Jun 2024 15:14:35 +0200 Subject: [PATCH] Fix sync (#16) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Prise en compte de la situation où aucune commune n'est fournie dans le dossier * Suppression de la limite implicite de 255 char pour le champ 'espèces_protégées_concernées' en base de données --- .../20240612130105_agrandir-champs-texte.js | 19 +++++++++++++++++++ ...nc-d\303\251marches-simplifi\303\251es.js" | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 migrations/20240612130105_agrandir-champs-texte.js diff --git a/migrations/20240612130105_agrandir-champs-texte.js b/migrations/20240612130105_agrandir-champs-texte.js new file mode 100644 index 00000000..f657ced7 --- /dev/null +++ b/migrations/20240612130105_agrandir-champs-texte.js @@ -0,0 +1,19 @@ +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +export function up(knex) { + return knex.schema.alterTable('dossier', (table) => { + table.text('espèces_protégées_concernées').alter(); + }); +}; + +/** + * @param { import("knex").Knex } knex + * @returns { Promise } + */ +export function down(knex) { + return knex.schema.alterTable('dossier', (table) => { + table.string('espèces_protégées_concernées').alter() + }); +}; diff --git "a/outils/sync-d\303\251marches-simplifi\303\251es.js" "b/outils/sync-d\303\251marches-simplifi\303\251es.js" index 7c1f70de..579211ca 100644 --- "a/outils/sync-d\303\251marches-simplifi\303\251es.js" +++ "b/outils/sync-d\303\251marches-simplifi\303\251es.js" @@ -83,8 +83,11 @@ const dossiers = démarche.dossiers.nodes.map(({ let régions; if(champCommunes){ - communes = champCommunes.rows.map(c => c.champs[0].commune) - départements = [... new Set(champCommunes.rows.map(c => c.champs[0].departement.code))] + communes = champCommunes.rows.map(c => c.champs[0].commune).filter(x => !!x) + + if(Array.isArray(communes) && communes.length >= 1){ + départements = [... new Set(champCommunes.rows.map(c => c.champs[0].departement.code))] + } } else{ if(champDépartements){