Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee91e7a91f | |||
| 392f862baa | |||
| 199476ec30 | |||
| c98a36f759 | |||
| 65e0f4c5f0 | |||
| bc7652f336 | |||
| 188383a882 | |||
| 7f3a0bcb21 | |||
| 3270abb7f6 | |||
| 2eb984a95f | |||
| 776126a481 | |||
| 816d0de324 | |||
| 90e9bc3c8c |
@@ -4,11 +4,11 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||||
|
|
||||||
name: Create Release
|
name: Auto-release d'un tag
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Auto-release d'un tag
|
name: auto-release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# decp.info
|
# decp.info
|
||||||
|
|
||||||
> v2.1.4
|
> v2.1.6
|
||||||
|
|
||||||
Outil d'exploration et de téléchargement des données essentielles de la commande publique.
|
Outil d'exploration et de téléchargement des données essentielles de la commande publique.
|
||||||
|
|
||||||
@@ -38,6 +38,15 @@ Ne pas oublier de mettre à jour les fichier .env.
|
|||||||
|
|
||||||
## Notes de version
|
## Notes de version
|
||||||
|
|
||||||
|
##### 2.1.6 (15 octobre 2025)
|
||||||
|
|
||||||
|
- Stabilisation de la vue marché
|
||||||
|
|
||||||
|
##### 2.1.5 (10 octobre 2025)
|
||||||
|
|
||||||
|
- réparation des filtres (notamment < > sur les montants)
|
||||||
|
- remplacement des valeurs "null" dans les tableaux par des cellules vides
|
||||||
|
|
||||||
##### 2.1.4 (8 octobre 2025)
|
##### 2.1.4 (8 octobre 2025)
|
||||||
|
|
||||||
- possibilité de filtrer sur le champ "Source"
|
- possibilité de filtrer sur le champ "Source"
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "decp.info"
|
name = "decp.info"
|
||||||
description = "Interface d'exploration et d'analyse des marchés publics français."
|
description = "Interface d'exploration et d'analyse des marchés publics français."
|
||||||
version = "2.1.4"
|
version = "2.1.6"
|
||||||
requires-python = ">= 3.10"
|
requires-python = ">= 3.10"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Colin Maudry", email = "colin+decp@maudry.com" }
|
{ name = "Colin Maudry", email = "colin+decp@maudry.com" }
|
||||||
|
|||||||
@@ -175,7 +175,6 @@ def get_acheteur_marches_data(url, acheteur_year: str) -> list[dict]:
|
|||||||
acheteur_siret = url.split("/")[-1]
|
acheteur_siret = url.split("/")[-1]
|
||||||
lff = df.lazy()
|
lff = df.lazy()
|
||||||
lff = lff.filter(pl.col("acheteur_id") == acheteur_siret)
|
lff = lff.filter(pl.col("acheteur_id") == acheteur_siret)
|
||||||
lff = lff.fill_null("")
|
|
||||||
lff = lff.select(
|
lff = lff.select(
|
||||||
"id",
|
"id",
|
||||||
"uid",
|
"uid",
|
||||||
@@ -204,6 +203,8 @@ def get_acheteur_marches_data(url, acheteur_year: str) -> list[dict]:
|
|||||||
)
|
)
|
||||||
def get_last_marches_table(data) -> html.Div:
|
def get_last_marches_table(data) -> html.Div:
|
||||||
dff = pl.DataFrame(data)
|
dff = pl.DataFrame(data)
|
||||||
|
dff = dff.cast(pl.String)
|
||||||
|
dff = dff.fill_null("")
|
||||||
dff = format_montant(dff)
|
dff = format_montant(dff)
|
||||||
columns, tooltip = setup_table_columns(
|
columns, tooltip = setup_table_columns(
|
||||||
dff,
|
dff,
|
||||||
|
|||||||
+2
-8
@@ -66,6 +66,7 @@ def get_marche_data(url) -> tuple[dict, list]:
|
|||||||
marche_uid = url.split("/")[-1]
|
marche_uid = url.split("/")[-1]
|
||||||
|
|
||||||
# Récupération des données du marché à partir du df global
|
# Récupération des données du marché à partir du df global
|
||||||
|
|
||||||
lff = df.lazy()
|
lff = df.lazy()
|
||||||
lff = lff.filter(pl.col("uid") == pl.lit(marche_uid))
|
lff = lff.filter(pl.col("uid") == pl.lit(marche_uid))
|
||||||
|
|
||||||
@@ -73,13 +74,9 @@ def get_marche_data(url) -> tuple[dict, list]:
|
|||||||
dff_titulaires = lff.select(cs.starts_with("titulaire")).collect(engine="streaming")
|
dff_titulaires = lff.select(cs.starts_with("titulaire")).collect(engine="streaming")
|
||||||
|
|
||||||
# Données du marché
|
# Données du marché
|
||||||
dff_marche = (
|
dff_marche = lff.unique("uid").collect(engine="streaming")
|
||||||
lff.select(~cs.starts_with("titulaires")).unique().collect(engine="streaming")
|
|
||||||
)
|
|
||||||
dff_marche = format_montant(dff_marche)
|
dff_marche = format_montant(dff_marche)
|
||||||
|
|
||||||
assert dff_marche.height == 1
|
|
||||||
|
|
||||||
return dff_marche.to_dicts()[0], dff_titulaires.to_dicts()
|
return dff_marche.to_dicts()[0], dff_titulaires.to_dicts()
|
||||||
|
|
||||||
|
|
||||||
@@ -93,7 +90,6 @@ def get_marche_data(url) -> tuple[dict, list]:
|
|||||||
def update_marche_info(marche, titulaires):
|
def update_marche_info(marche, titulaires):
|
||||||
def make_parameter(col):
|
def make_parameter(col):
|
||||||
column_object = data_schema.get(col)
|
column_object = data_schema.get(col)
|
||||||
print(column_object)
|
|
||||||
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 marche[col]:
|
||||||
@@ -110,8 +106,6 @@ def update_marche_info(marche, titulaires):
|
|||||||
|
|
||||||
# Dates
|
# Dates
|
||||||
elif col in ["dateNotification", "datePublicationDonnees"]:
|
elif col in ["dateNotification", "datePublicationDonnees"]:
|
||||||
print(marche[col])
|
|
||||||
|
|
||||||
value = datetime.fromisoformat(marche[col]).strftime("%d/%m/%Y")
|
value = datetime.fromisoformat(marche[col]).strftime("%d/%m/%Y")
|
||||||
|
|
||||||
# Listes
|
# Listes
|
||||||
|
|||||||
@@ -182,9 +182,6 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
|
|||||||
if len(sort_by) > 0:
|
if len(sort_by) > 0:
|
||||||
lff = sort_table_data(lff, sort_by)
|
lff = sort_table_data(lff, sort_by)
|
||||||
|
|
||||||
# Remplace les strings null par "", mais pas les numeric null
|
|
||||||
lff = lff.fill_null("")
|
|
||||||
|
|
||||||
# Matérialisation des filtres
|
# Matérialisation des filtres
|
||||||
dff: pl.DataFrame = lff.collect()
|
dff: pl.DataFrame = lff.collect()
|
||||||
|
|
||||||
@@ -196,6 +193,12 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
|
|||||||
# end_row = (page_current + 1) * page_size
|
# end_row = (page_current + 1) * page_size
|
||||||
dff = dff.slice(start_row, page_size)
|
dff = dff.slice(start_row, page_size)
|
||||||
|
|
||||||
|
# Tout devient string
|
||||||
|
dff = dff.cast(pl.String)
|
||||||
|
|
||||||
|
# Remplace les strings null par "", mais pas les numeric null
|
||||||
|
dff = dff.fill_null("")
|
||||||
|
|
||||||
# Ajout des liens vers l'annuaire des entreprises
|
# Ajout des liens vers l'annuaire des entreprises
|
||||||
dff = add_links(dff)
|
dff = add_links(dff)
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,6 @@ def get_titulaire_marches_data(url, titulaire_year: str) -> list[dict]:
|
|||||||
(pl.col("titulaire_id") == titulaire_siret)
|
(pl.col("titulaire_id") == titulaire_siret)
|
||||||
& (pl.col("titulaire_typeIdentifiant") == "SIRET")
|
& (pl.col("titulaire_typeIdentifiant") == "SIRET")
|
||||||
)
|
)
|
||||||
lff = lff.fill_null("")
|
|
||||||
lff = lff.select(
|
lff = lff.select(
|
||||||
"id",
|
"id",
|
||||||
"uid",
|
"uid",
|
||||||
@@ -218,6 +217,8 @@ def get_last_marches_table(data) -> html.Div:
|
|||||||
]
|
]
|
||||||
|
|
||||||
dff = pl.DataFrame(data)
|
dff = pl.DataFrame(data)
|
||||||
|
dff = dff.cast(pl.String)
|
||||||
|
dff = dff.fill_null("")
|
||||||
dff = format_montant(dff)
|
dff = format_montant(dff)
|
||||||
columns, tooltip = setup_table_columns(
|
columns, tooltip = setup_table_columns(
|
||||||
dff, hideable=False, exclude=["acheteur_id", "id"]
|
dff, hideable=False, exclude=["acheteur_id", "id"]
|
||||||
|
|||||||
+35
-19
@@ -126,7 +126,8 @@ def format_number(number) -> str:
|
|||||||
def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
||||||
def format_function(expr, scale=None):
|
def format_function(expr, scale=None):
|
||||||
# https://stackoverflow.com/a/78636786
|
# https://stackoverflow.com/a/78636786
|
||||||
expr = expr.cast(pl.String).str.splitn(".", 2)
|
expr = expr.cast(pl.String)
|
||||||
|
expr = expr.str.splitn(".", 2)
|
||||||
|
|
||||||
num = expr.struct[0]
|
num = expr.struct[0]
|
||||||
frac = expr.struct[1]
|
frac = expr.struct[1]
|
||||||
@@ -145,7 +146,13 @@ def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
|||||||
.otherwise(pl.lit(""))
|
.otherwise(pl.lit(""))
|
||||||
)
|
)
|
||||||
|
|
||||||
return num + frac + pl.lit(" €")
|
montant: pl.Expr = (
|
||||||
|
pl.when((num + frac) == pl.lit(""))
|
||||||
|
.then(pl.lit(""))
|
||||||
|
.otherwise(num + frac + pl.lit(" €"))
|
||||||
|
)
|
||||||
|
|
||||||
|
return montant
|
||||||
|
|
||||||
dff = dff.with_columns(pl.col("montant").pipe(format_function).alias("montant"))
|
dff = dff.with_columns(pl.col("montant").pipe(format_function).alias("montant"))
|
||||||
return dff
|
return dff
|
||||||
@@ -211,21 +218,30 @@ def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
|
|||||||
filtering_expressions = filter_query.split(" && ")
|
filtering_expressions = filter_query.split(" && ")
|
||||||
for filter_part in filtering_expressions:
|
for filter_part in filtering_expressions:
|
||||||
col_name, operator, filter_value = split_filter_part(filter_part)
|
col_name, operator, filter_value = split_filter_part(filter_part)
|
||||||
|
|
||||||
col_type = str(schema[col_name])
|
col_type = str(schema[col_name])
|
||||||
if debug:
|
if debug:
|
||||||
print("filter_value:", filter_value)
|
print("filter_value:", filter_value)
|
||||||
print("filter_value_type:", type(filter_value))
|
print("filter_value_type:", type(filter_value))
|
||||||
|
print("operator:", operator)
|
||||||
print("col_type:", col_type)
|
print("col_type:", col_type)
|
||||||
|
|
||||||
if col_type == "Date":
|
lff = lff.filter(pl.col(col_name).is_not_null())
|
||||||
# Convertir la colonne en chaînes de caractères
|
|
||||||
lff = dates_to_strings(lff, col_name)
|
|
||||||
|
|
||||||
if operator in ("<", "<=", ">", ">="):
|
if col_type == "Date":
|
||||||
lff = lff.filter(
|
# Convertir la colonne date en chaînes de caractères
|
||||||
pl.col(col_name).is_not_null() & (pl.col(col_name) != pl.lit(""))
|
lff = dates_to_strings(lff, col_name)
|
||||||
)
|
col_type = "String"
|
||||||
|
if col_type == "String":
|
||||||
|
lff = lff.filter(pl.col(col_name) != pl.lit(""))
|
||||||
|
|
||||||
|
elif col_type.startswith("Int") or col_type.startswith("Float"):
|
||||||
|
try:
|
||||||
|
filter_value = int(filter_value)
|
||||||
|
except ValueError:
|
||||||
|
logger.error(f"Invalid numeric filter value: {filter_value}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if operator in ("contains", "<", "<=", ">", ">="):
|
||||||
if operator == "<":
|
if operator == "<":
|
||||||
lff = lff.filter(pl.col(col_name) < filter_value)
|
lff = lff.filter(pl.col(col_name) < filter_value)
|
||||||
elif operator == ">":
|
elif operator == ">":
|
||||||
@@ -234,17 +250,17 @@ def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
|
|||||||
lff = lff.filter(pl.col(col_name) >= filter_value)
|
lff = lff.filter(pl.col(col_name) >= filter_value)
|
||||||
elif operator == "<=":
|
elif operator == "<=":
|
||||||
lff = lff.filter(pl.col(col_name) <= filter_value)
|
lff = lff.filter(pl.col(col_name) <= filter_value)
|
||||||
|
elif operator == "contains":
|
||||||
|
if col_type in ["String", "Date"]:
|
||||||
|
lff = lff.filter(
|
||||||
|
pl.col(col_name).str.contains("(?i)" + filter_value)
|
||||||
|
)
|
||||||
elif col_type.startswith("Int") or col_type.startswith("Float"):
|
elif col_type.startswith("Int") or col_type.startswith("Float"):
|
||||||
try:
|
|
||||||
filter_value = int(filter_value)
|
|
||||||
except ValueError:
|
|
||||||
logger.error(f"Invalid numeric filter value: {filter_value}")
|
|
||||||
continue
|
|
||||||
lff = lff.filter(pl.col(col_name) == filter_value)
|
lff = lff.filter(pl.col(col_name) == filter_value)
|
||||||
|
else:
|
||||||
elif operator == "contains" and col_type in ["String", "Date"]:
|
logger.error(f"Invalid column type: {col_type}")
|
||||||
lff = lff.filter(pl.col(col_name).str.contains("(?i)" + filter_value))
|
else:
|
||||||
|
logger.error(f"Invalid operator: {operator}")
|
||||||
|
|
||||||
# elif operator == 'datestartswith':
|
# elif operator == 'datestartswith':
|
||||||
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")
|
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")
|
||||||
|
|||||||
Reference in New Issue
Block a user