From ed32b0f66b12abc34595b6b2651ac53d678dd179 Mon Sep 17 00:00:00 2001 From: Colin Maudry Date: Sun, 7 Jun 2026 18:56:16 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9duction=20des=20petites=20erreurs=20qui?= =?UTF-8?q?=20polluent=20les=20logs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/arbre/liste_marches_org.py | 10 +++++++--- src/pages/etapes.py | 4 ++-- src/pages/marche.py | 3 ++- src/utils/data.py | 18 ++++++++++-------- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/pages/arbre/liste_marches_org.py b/src/pages/arbre/liste_marches_org.py index 26cba1c..a5d9fd9 100644 --- a/src/pages/arbre/liste_marches_org.py +++ b/src/pages/arbre/liste_marches_org.py @@ -2,6 +2,7 @@ import polars as pl from dash import Input, Output, callback, dcc, html, register_page from src.db import get_cursor +from src.utils import logger from src.utils.data import DF_ACHETEURS, DF_TITULAIRES NAME = "Liste des marchés publics" @@ -27,9 +28,12 @@ def make_org_nom_verbe(org_type, org_id) -> tuple: def get_title(code, org_type, org_id): - org_nom, verbe = make_org_nom_verbe(org_type, org_id) - - return f"Marchés publics {verbe} par {org_nom} | decp.info" + if org_type: + org_nom, verbe = make_org_nom_verbe(org_type, org_id) + return f"Marchés publics {verbe} par {org_nom} | decp.info" + else: + logger.warning(f"Pas de org_type pour org_id: {org_id}") + return "Marchés publics | decp.info" def get_description(code, org_type, org_id): diff --git a/src/pages/etapes.py b/src/pages/etapes.py index 3f2f4a5..9af912e 100644 --- a/src/pages/etapes.py +++ b/src/pages/etapes.py @@ -2,7 +2,7 @@ from dash import Input, Output, State, callback, ctx, dcc, html, register_page from src.utils.seo import META_CONTENT -NAME = "Quelles données pour quelles étapes et quels seuils ?" +NAME = "Quelles données pour quelles étapes et quels seuils dans les marchés publics ?" register_page( __name__, @@ -293,5 +293,5 @@ def _show_detail(*args): return None, None content = ALL_CONTENT.get(triggered) if content is None: - return dcc.Markdown("*Fiche en cours de rédaction.*"), triggered + return dcc.Markdown(f"*Fiche en cours de rédaction.* {triggered}"), triggered return dcc.Markdown(content), triggered diff --git a/src/pages/marche.py b/src/pages/marche.py index 9587b56..49b42be 100644 --- a/src/pages/marche.py +++ b/src/pages/marche.py @@ -109,7 +109,7 @@ def update_marche_info(marche, titulaires): column_object = DATA_SCHEMA.get(col) column_name = column_object.get("title") if column_object else col - if col in marche: + if marche and col in marche: if col == "acheteur_nom": value = html.A( href=f"/acheteurs/{marche['acheteur_id']}", @@ -134,6 +134,7 @@ def update_marche_info(marche, titulaires): "considerationsSociales", "considerationsEnvironnementales", ] + and col in marche and "," in marche[col] ): col_values = marche[col].split(", ") diff --git a/src/utils/data.py b/src/utils/data.py index 0c792a5..c5304d5 100644 --- a/src/utils/data.py +++ b/src/utils/data.py @@ -53,14 +53,16 @@ def get_departements_geojson() -> dict: return geojson -def get_departement_region(code_postal): - if code_postal > "97000": - code_departement = code_postal[:3] - else: - code_departement = code_postal[:2] - nom_departement = DEPARTEMENTS[code_departement]["departement"] - nom_region = DEPARTEMENTS[code_departement]["region"] - return code_departement, nom_departement, nom_region +def get_departement_region(code_postal: str | None): + if code_postal: + if code_postal > "97000": + code_departement = code_postal[:3] + else: + code_departement = code_postal[:2] + nom_departement = DEPARTEMENTS[code_departement]["departement"] + nom_region = DEPARTEMENTS[code_departement]["region"] + return code_departement, nom_departement, nom_region + return "", "", "" def get_data_schema() -> dict: