Réduction des petites erreurs
This commit is contained in:
@@ -11,8 +11,10 @@ import plotly.graph_objects as go
|
|||||||
import polars as pl
|
import polars as pl
|
||||||
from dash import dash_table, dcc, html
|
from dash import dash_table, dcc, html
|
||||||
from dash_extensions.javascript import Namespace
|
from dash_extensions.javascript import Namespace
|
||||||
|
from polars.exceptions import ColumnNotFoundError
|
||||||
|
|
||||||
from src.db import schema
|
from src.db import schema
|
||||||
|
from src.utils import logger
|
||||||
from src.utils.data import DATA_SCHEMA, DEPARTEMENTS_GEOJSON
|
from src.utils.data import DATA_SCHEMA, DEPARTEMENTS_GEOJSON
|
||||||
from src.utils.table import add_links, format_number, setup_table_columns
|
from src.utils.table import add_links, format_number, setup_table_columns
|
||||||
|
|
||||||
@@ -833,7 +835,11 @@ def get_top_org_table(data, org_type: str, extra_columns: list, filters: bool =
|
|||||||
lff = lff.cast(pl.String)
|
lff = lff.cast(pl.String)
|
||||||
lff = lff.fill_null("")
|
lff = lff.fill_null("")
|
||||||
|
|
||||||
|
try:
|
||||||
dff: pl.DataFrame = lff.collect(engine="streaming")
|
dff: pl.DataFrame = lff.collect(engine="streaming")
|
||||||
|
except ColumnNotFoundError:
|
||||||
|
logger.warning(f"get_top_org_table: column not found. {lff.collect_schema()}")
|
||||||
|
return html.Div()
|
||||||
|
|
||||||
if dff.height == 0:
|
if dff.height == 0:
|
||||||
return html.Div()
|
return html.Div()
|
||||||
|
|||||||
+1
-1
@@ -109,7 +109,7 @@ def update_marche_info(marche, titulaires):
|
|||||||
column_object = DATA_SCHEMA.get(col)
|
column_object = DATA_SCHEMA.get(col)
|
||||||
column_name = column_object.get("title") if column_object else col
|
column_name = column_object.get("title") if column_object else col
|
||||||
|
|
||||||
if marche[col]:
|
if col in marche:
|
||||||
if col == "acheteur_nom":
|
if col == "acheteur_nom":
|
||||||
value = html.A(
|
value = html.A(
|
||||||
href=f"/acheteurs/{marche['acheteur_id']}",
|
href=f"/acheteurs/{marche['acheteur_id']}",
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ from src.utils import logger
|
|||||||
logging.getLogger("httpx").setLevel("WARNING")
|
logging.getLogger("httpx").setLevel("WARNING")
|
||||||
|
|
||||||
|
|
||||||
def get_annuaire_data(siret: str) -> dict:
|
def get_annuaire_data(siret: str) -> dict | None:
|
||||||
url = f"https://recherche-entreprises.api.gouv.fr/search?q={siret}"
|
url = f"https://recherche-entreprises.api.gouv.fr/search?q={siret}"
|
||||||
try:
|
try:
|
||||||
response = get(url).raise_for_status()
|
response = get(url).raise_for_status()
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ def make_org_jsonld(org_id, org_type, org_name=None, type_org_id="SIRET") -> dic
|
|||||||
address = None
|
address = None
|
||||||
if type_org_id.lower() == "siret" and len(org_id) == 14:
|
if type_org_id.lower() == "siret" and len(org_id) == 14:
|
||||||
annuaire_data = get_annuaire_data(org_id)
|
annuaire_data = get_annuaire_data(org_id)
|
||||||
|
if not annuaire_data:
|
||||||
|
return {}
|
||||||
annuaire_address = annuaire_data["matching_etablissements"][0]
|
annuaire_address = annuaire_data["matching_etablissements"][0]
|
||||||
code_postal = annuaire_address["code_postal"]
|
code_postal = annuaire_address["code_postal"]
|
||||||
commune = annuaire_address["libelle_commune"]
|
commune = annuaire_address["libelle_commune"]
|
||||||
|
|||||||
Reference in New Issue
Block a user