Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 65e0f4c5f0 | |||
| bc7652f336 | |||
| 188383a882 | |||
| 7f3a0bcb21 | |||
| 3270abb7f6 | |||
| 2eb984a95f | |||
| 776126a481 | |||
| 816d0de324 | |||
| 90e9bc3c8c |
@@ -4,11 +4,11 @@ on:
|
||||
tags:
|
||||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
|
||||
|
||||
name: Create Release
|
||||
name: Auto-release d'un tag
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Auto-release d'un tag
|
||||
name: auto-release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
||||
@@ -38,6 +38,11 @@ Ne pas oublier de mettre à jour les fichier .env.
|
||||
|
||||
## Notes de version
|
||||
|
||||
##### 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)
|
||||
|
||||
- possibilité de filtrer sur le champ "Source"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "decp.info"
|
||||
description = "Interface d'exploration et d'analyse des marchés publics français."
|
||||
version = "2.1.4"
|
||||
version = "2.1.5"
|
||||
requires-python = ">= 3.10"
|
||||
authors = [
|
||||
{ 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]
|
||||
lff = df.lazy()
|
||||
lff = lff.filter(pl.col("acheteur_id") == acheteur_siret)
|
||||
lff = lff.fill_null("")
|
||||
lff = lff.select(
|
||||
"id",
|
||||
"uid",
|
||||
@@ -204,6 +203,8 @@ def get_acheteur_marches_data(url, acheteur_year: str) -> list[dict]:
|
||||
)
|
||||
def get_last_marches_table(data) -> html.Div:
|
||||
dff = pl.DataFrame(data)
|
||||
dff = dff.cast(pl.String)
|
||||
dff = dff.fill_null("")
|
||||
dff = format_montant(dff)
|
||||
columns, tooltip = setup_table_columns(
|
||||
dff,
|
||||
|
||||
@@ -182,9 +182,6 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
|
||||
if len(sort_by) > 0:
|
||||
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
|
||||
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
|
||||
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
|
||||
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_typeIdentifiant") == "SIRET")
|
||||
)
|
||||
lff = lff.fill_null("")
|
||||
lff = lff.select(
|
||||
"id",
|
||||
"uid",
|
||||
@@ -218,6 +217,8 @@ def get_last_marches_table(data) -> html.Div:
|
||||
]
|
||||
|
||||
dff = pl.DataFrame(data)
|
||||
dff = dff.cast(pl.String)
|
||||
dff = dff.fill_null("")
|
||||
dff = format_montant(dff)
|
||||
columns, tooltip = setup_table_columns(
|
||||
dff, hideable=False, exclude=["acheteur_id", "id"]
|
||||
|
||||
+34
-19
@@ -126,7 +126,7 @@ def format_number(number) -> str:
|
||||
def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
||||
def format_function(expr, scale=None):
|
||||
# https://stackoverflow.com/a/78636786
|
||||
expr = expr.cast(pl.String).str.splitn(".", 2)
|
||||
expr = expr.str.splitn(".", 2)
|
||||
|
||||
num = expr.struct[0]
|
||||
frac = expr.struct[1]
|
||||
@@ -145,7 +145,13 @@ def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
|
||||
.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"))
|
||||
return dff
|
||||
@@ -211,21 +217,30 @@ def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
|
||||
filtering_expressions = filter_query.split(" && ")
|
||||
for filter_part in filtering_expressions:
|
||||
col_name, operator, filter_value = split_filter_part(filter_part)
|
||||
|
||||
col_type = str(schema[col_name])
|
||||
if debug:
|
||||
print("filter_value:", filter_value)
|
||||
print("filter_value_type:", type(filter_value))
|
||||
print("operator:", operator)
|
||||
print("col_type:", col_type)
|
||||
|
||||
if col_type == "Date":
|
||||
# Convertir la colonne en chaînes de caractères
|
||||
lff = dates_to_strings(lff, col_name)
|
||||
lff = lff.filter(pl.col(col_name).is_not_null())
|
||||
|
||||
if operator in ("<", "<=", ">", ">="):
|
||||
lff = lff.filter(
|
||||
pl.col(col_name).is_not_null() & (pl.col(col_name) != pl.lit(""))
|
||||
)
|
||||
if col_type == "Date":
|
||||
# Convertir la colonne date en chaînes de caractères
|
||||
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 == "<":
|
||||
lff = lff.filter(pl.col(col_name) < filter_value)
|
||||
elif operator == ">":
|
||||
@@ -234,17 +249,17 @@ def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
|
||||
lff = lff.filter(pl.col(col_name) >= filter_value)
|
||||
elif operator == "<=":
|
||||
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"):
|
||||
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)
|
||||
|
||||
elif operator == "contains" and col_type in ["String", "Date"]:
|
||||
lff = lff.filter(pl.col(col_name).str.contains("(?i)" + filter_value))
|
||||
else:
|
||||
logger.error(f"Invalid column type: {col_type}")
|
||||
else:
|
||||
logger.error(f"Invalid operator: {operator}")
|
||||
|
||||
# elif operator == 'datestartswith':
|
||||
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")
|
||||
|
||||
Reference in New Issue
Block a user