Skip to content

Commit

Permalink
Fix sync (#16)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
DavidBruant authored Jun 12, 2024
1 parent 85e490f commit 9e1af43
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
19 changes: 19 additions & 0 deletions migrations/20240612130105_agrandir-champs-texte.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
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<void> }
*/
export function down(knex) {
return knex.schema.alterTable('dossier', (table) => {
table.string('espèces_protégées_concernées').alter()
});
};
7 changes: 5 additions & 2 deletions outils/sync-démarches-simplifiées.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down

0 comments on commit 9e1af43

Please sign in to comment.