arbre/liste_marches_org.py : requêtes DuckDB pour les listes de marchés (#71)
This commit is contained in:
@@ -1,12 +1,8 @@
|
|||||||
import polars as pl
|
import polars as pl
|
||||||
from dash import Input, Output, callback, dcc, html, register_page
|
from dash import Input, Output, callback, dcc, html, register_page
|
||||||
|
|
||||||
from src.utils import (
|
from src.db import get_cursor
|
||||||
df_acheteurs,
|
from src.utils import df_acheteurs, df_titulaires
|
||||||
df_acheteurs_marches,
|
|
||||||
df_titulaires,
|
|
||||||
df_titulaires_marches,
|
|
||||||
)
|
|
||||||
|
|
||||||
name = "Liste des marchés publics"
|
name = "Liste des marchés publics"
|
||||||
|
|
||||||
@@ -68,28 +64,34 @@ def liste_marches(url):
|
|||||||
org_id = url.split("/")[-1]
|
org_id = url.split("/")[-1]
|
||||||
|
|
||||||
def make_link_list() -> list:
|
def make_link_list() -> list:
|
||||||
link_list = []
|
table = (
|
||||||
if org_type == "acheteur":
|
"acheteurs_marches"
|
||||||
df = df_acheteurs_marches
|
if org_type == "acheteur"
|
||||||
elif org_type == "titulaire":
|
else "titulaires_marches"
|
||||||
df = df_titulaires_marches
|
if org_type == "titulaire"
|
||||||
else:
|
else None
|
||||||
|
)
|
||||||
|
if table is None:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
rows = (
|
||||||
df = df.filter(pl.col(f"{org_type}_id") == org_id)
|
get_cursor()
|
||||||
|
.execute(
|
||||||
for row in df.iter_rows(named=True):
|
f"SELECT uid, objet FROM {table} WHERE {org_type}_id = ?",
|
||||||
li = html.Li(
|
[org_id],
|
||||||
[
|
|
||||||
dcc.Link(
|
|
||||||
row["objet"],
|
|
||||||
href=f"/marches/{row['uid']}",
|
|
||||||
title=f"Marchés public attribué : {row['objet']}",
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
link_list.append(li)
|
.fetchall()
|
||||||
return link_list
|
)
|
||||||
|
|
||||||
|
return [
|
||||||
|
html.Li(
|
||||||
|
dcc.Link(
|
||||||
|
objet,
|
||||||
|
href=f"/marches/{uid}",
|
||||||
|
title=f"Marchés public attribué : {objet}",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
for uid, objet in rows
|
||||||
|
]
|
||||||
|
|
||||||
nom, verbe = make_org_nom_verbe(org_type, org_id)
|
nom, verbe = make_org_nom_verbe(org_type, org_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user