Derniers marché notifiés #28

This commit is contained in:
Colin Maudry
2025-09-27 11:48:57 +02:00
parent 2fc319d1bc
commit df04286a4a
3 changed files with 113 additions and 50 deletions
+4 -1
View File
@@ -71,7 +71,10 @@ td[data-dash-column="objet"] {
}
/* Alternance des couleurs pour les lignes */
#table tr:nth-child(even) td {
.marches_table {
font-family: sans-serif;
}
.marches_table .cell-table tr:nth-child(even) td {
background-color: #feeeee;
}
+63 -6
View File
@@ -1,5 +1,7 @@
import dash
from dash import Input, Output, callback, dcc, html, register_page
import polars as pl
from dash import Input, Output, callback, dash_table, dcc, html, register_page
from src.utils import lf
register_page(
__name__,
@@ -11,14 +13,15 @@ register_page(
# 21690123100011
print(dash.page_registry["pages.acheteur"])
layout = [
dcc.Store(id="acheteur_data", storage_type="memory"),
dcc.Location(id="url", refresh="callback-nav"),
html.Div(
className="container",
children=[
html.H2(id="acheteur_title", children=""),
html.H3("Derniers marchés publics notifiés"),
html.Div(id="acheteur_last_marches", children=""),
],
),
]
@@ -30,6 +33,60 @@ layout = [
)
def update_acheteur(url):
acheteur_siret = url.split("/")[-1]
acheteur_title = acheteur_siret
if len(acheteur_siret) != 14:
return f"Le SIRET renseigné doit faire 14 caractères ({acheteur_siret})"
return acheteur_title
return acheteur_siret
@callback(
Output(component_id="acheteur_data", component_property="data"),
Input(component_id="url", component_property="pathname"),
)
def get_acheteur_marches_data(url) -> pl.LazyFrame:
acheteur_siret = url.split("/")[-1]
lff = lf.filter(pl.col("acheteur_id") == acheteur_siret)
lff = lff.select(
"uid",
"objet",
"dateNotification",
"titulaire_nom",
"montant",
"codeCPV",
"dureeMois",
)
lff = lff.sort("dateNotification", descending=True, nulls_last=True)
data = lff.collect(engine="streaming").to_dicts()
return data
@callback(
Output(component_id="acheteur_last_marches", component_property="children"),
Input(component_id="acheteur_data", component_property="data"),
)
def get_last_marches_table(data) -> html.Div:
table = html.Div(
className="marches_table",
children=dash_table.DataTable(
data=data[:20],
style_cell_conditional=[
{
"if": {"column_id": "objet"},
"minWidth": "300px",
"textAlign": "left",
"overflow": "hidden",
"lineHeight": "14px",
"whiteSpace": "normal",
},
{
"if": {"column_id": "titulaire_nom"},
"minWidth": "200px",
"textAlign": "left",
"overflow": "hidden",
"lineHeight": "14px",
"whiteSpace": "normal",
},
],
),
)
return table
+46 -43
View File
@@ -47,49 +47,52 @@ schema = lf.collect_schema()
title = "Tableau"
register_page(__name__, path="/", title="decp.info", name=title, order=1)
datatable = dash_table.DataTable(
cell_selectable=False,
id="table",
page_size=20,
page_current=0,
page_action="custom",
filter_action="custom",
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
columns=[
{
"name": i,
"id": i,
"presentation": "markdown",
"type": "text",
"format": {"nully": "N/A"},
"hideable": True,
}
for i in lf.collect_schema().names()
],
sort_action="custom",
sort_mode="multi",
sort_by=[],
row_deletable=False,
style_cell_conditional=[
{
"if": {"column_id": "objet"},
"minWidth": "350px",
"textAlign": "left",
"overflow": "hidden",
"lineHeight": "14px",
"whiteSpace": "normal",
},
{
"if": {"column_id": "acheteur_nom"},
"minWidth": "250px",
"textAlign": "left",
"overflow": "hidden",
"lineHeight": "14px",
"whiteSpace": "normal",
},
],
data_timestamp=0,
markdown_options={"html": True},
datatable = html.Div(
className="marches_table",
children=dash_table.DataTable(
cell_selectable=False,
id="table",
page_size=20,
page_current=0,
page_action="custom",
filter_action="custom",
filter_options={"case": "insensitive", "placeholder_text": "Filtrer..."},
columns=[
{
"name": i,
"id": i,
"presentation": "markdown",
"type": "text",
"format": {"nully": "N/A"},
"hideable": True,
}
for i in lf.collect_schema().names()
],
sort_action="custom",
sort_mode="multi",
sort_by=[],
row_deletable=False,
style_cell_conditional=[
{
"if": {"column_id": "objet"},
"minWidth": "350px",
"textAlign": "left",
"overflow": "hidden",
"lineHeight": "14px",
"whiteSpace": "normal",
},
{
"if": {"column_id": "acheteur_nom"},
"minWidth": "250px",
"textAlign": "left",
"overflow": "hidden",
"lineHeight": "14px",
"whiteSpace": "normal",
},
],
data_timestamp=0,
markdown_options={"html": True},
),
)
layout = [