fix(aep-15): description, nom et ville du modèle bornés avant la colonne

Checkpoint 22/11, correction 4. Ces trois textes n'étaient bornés que par
leur type. lib/extraction.js::texteBorne les coupe à 300, 200 et 100
caractères (en points de code), une chaîne vide vaut null. Antérieur au
lot, mais le lot touche ces lignes. Tests : texteBorne seul, et un PATCH
à blanc où le modèle rend 1 200 / 450 / 400 caractères.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jules
2026-11-22 11:08:21 +01:00
co-authored by Claude Opus 5.5
parent 7e81b4732a
commit 3a93c84bec
4 changed files with 50 additions and 7 deletions
+9 -6
View File
@@ -35,7 +35,7 @@ import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import { messageFicheEnrichie, hoteDuLien } from './lib/messageNtfy.js';
import { recupererPage, controlerAdresse, tableRedirections } from './lib/recupererPage.js';
import { extractionDepuisModele } from './lib/extraction.js';
import { extractionDepuisModele, texteBorne, MAX_COLONNES } from './lib/extraction.js';
import {
CHAMPS_BASE, CHAMPS_ECRITS, VERSION_SORTIE, baseDepuisFiches, passeAdresse, resoudreLot,
propositionTaxonomie, statutApresEnrichissement, relireScrape, lienPrincipal, lirePagine,
@@ -683,7 +683,8 @@ async function run() {
const normalizedTags = [...new Set(rawTags.map(normalizeTag).filter(Boolean))];
const updateData = {
description_enrichie: typeof enriched.description === 'string' ? enriched.description : null,
// Checkpoint 22/11 : les textes du modèle écrits en colonne sont bornés (300, 200, 100).
description_enrichie: texteBorne(enriched.description, MAX_COLONNES.description_enrichie),
tags_fonction: normalizedTags.join(','),
moderation_status: statutApresEnrichissement(resolu?.r6),
ai_processed: true,
@@ -700,11 +701,13 @@ async function run() {
};
// Nom : ne remplacer que le placeholder posé par le formulaire assoupli (B5-M1).
if (typeof enriched.nom === 'string' && enriched.nom && typeof row.nom === 'string' && row.nom.startsWith('[à qualifier]')) {
updateData.nom = enriched.nom;
const nomPropose = texteBorne(enriched.nom, MAX_COLONNES.nom);
if (nomPropose && typeof row.nom === 'string' && row.nom.startsWith('[à qualifier]')) {
updateData.nom = nomPropose;
}
if (typeof enriched.ville === 'string' && enriched.ville && !row.localisation_ville) {
updateData.localisation_ville = enriched.ville;
const villeProposee = texteBorne(enriched.ville, MAX_COLONNES.localisation_ville);
if (villeProposee && !row.localisation_ville) {
updateData.localisation_ville = villeProposee;
}
// submission_type : ne réajuster que si l'utilisateur n'avait pas choisi de chip
// (marqueur posé par utils/submitLibre.ts::toOrgaPayload — "Type : non précisé").