Utilisation des stats produites par decp_processing
This commit is contained in:
@@ -5,6 +5,8 @@ import plotly.express as px
|
|||||||
import polars as pl
|
import polars as pl
|
||||||
from dash import dash_table, dcc, html
|
from dash import dash_table, dcc, html
|
||||||
|
|
||||||
|
from src.utils import format_number
|
||||||
|
|
||||||
|
|
||||||
def get_map_count_marches(df: pl.DataFrame):
|
def get_map_count_marches(df: pl.DataFrame):
|
||||||
lf = df.lazy()
|
lf = df.lazy()
|
||||||
@@ -56,6 +58,25 @@ def get_map_count_marches(df: pl.DataFrame):
|
|||||||
return fig
|
return fig
|
||||||
|
|
||||||
|
|
||||||
|
def get_yearly_statistics(statistics, today_str) -> html.Div:
|
||||||
|
children = []
|
||||||
|
|
||||||
|
for year in reversed(range(2018, int(today_str.split("/")[-1]) + 1)):
|
||||||
|
year = str(year)
|
||||||
|
stat_year = statistics[year]
|
||||||
|
md = dcc.Markdown(f"""
|
||||||
|
#### {year}
|
||||||
|
|
||||||
|
- Nombre de marchés publics et accords-cadres : {format_number(stat_year["nb_notifications_marches"])}
|
||||||
|
- Nombre d'acheteurs publics : {format_number(stat_year["nb_acheteurs_uniques"])}
|
||||||
|
- Nombre de titulaires : {format_number(stat_year["nb_titulaires_uniques"])}
|
||||||
|
|
||||||
|
""")
|
||||||
|
children.append(md)
|
||||||
|
|
||||||
|
return html.Div(children=children)
|
||||||
|
|
||||||
|
|
||||||
def get_barchart_sources(df: pl.DataFrame, type_date: str):
|
def get_barchart_sources(df: pl.DataFrame, type_date: str):
|
||||||
lf = df.lazy()
|
lf = df.lazy()
|
||||||
labels = {
|
labels = {
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from dash import dcc, html, register_page
|
from dash import dcc, html, register_page
|
||||||
|
|
||||||
from src.figures import get_barchart_sources, get_map_count_marches
|
from src.figures import (
|
||||||
from src.utils import df, meta_content
|
get_barchart_sources,
|
||||||
|
get_map_count_marches,
|
||||||
|
get_yearly_statistics,
|
||||||
|
)
|
||||||
|
from src.utils import df, format_number, get_statistics, meta_content
|
||||||
|
|
||||||
name = "Statistiques"
|
name = "Statistiques"
|
||||||
|
|
||||||
@@ -15,6 +21,8 @@ register_page(
|
|||||||
order=3,
|
order=3,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
statistics: dict = get_statistics()
|
||||||
|
today_str = datetime.fromisoformat(statistics["datetime"]).strftime("%d/%m/%Y")
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
html.Div(
|
html.Div(
|
||||||
@@ -38,6 +46,20 @@ layout = [
|
|||||||
toutes les [contributions](/a-propos#contribuer) sont les bienvenues pour atteindre l'exhaustivité.
|
toutes les [contributions](/a-propos#contribuer) sont les bienvenues pour atteindre l'exhaustivité.
|
||||||
"""),
|
"""),
|
||||||
dcc.Graph(figure=get_map_count_marches(df)),
|
dcc.Graph(figure=get_map_count_marches(df)),
|
||||||
|
html.H2(
|
||||||
|
f"Statistiques générales sur les marchés (au {today_str})",
|
||||||
|
id="marches",
|
||||||
|
),
|
||||||
|
html.P(
|
||||||
|
"À noter qu'une fois un marché attribué ses données essentielles peuvent malheureusement mettre plusieurs mois à être publiées par l'acheteur."
|
||||||
|
),
|
||||||
|
html.H4("Statistiques cumulées"),
|
||||||
|
dcc.Markdown(f"""
|
||||||
|
- Nombre de marchés publics et accords-cadres : {format_number(statistics["nb_marches"])}
|
||||||
|
- Nombre d'acheteurs publics : {format_number(statistics["nb_acheteurs_uniques"])}
|
||||||
|
- Nombre de titulaires uniques : {format_number(statistics["nb_titulaires_uniques"])}
|
||||||
|
"""),
|
||||||
|
get_yearly_statistics(statistics, today_str),
|
||||||
dcc.Graph(
|
dcc.Graph(
|
||||||
figure=get_barchart_sources(df, "dateNotification")
|
figure=get_barchart_sources(df, "dateNotification")
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -240,6 +240,17 @@ def get_org_data(dff: pl.DataFrame, org_type: str) -> pl.DataFrame:
|
|||||||
return lff.collect()
|
return lff.collect()
|
||||||
|
|
||||||
|
|
||||||
|
def get_statistics() -> dict:
|
||||||
|
return (
|
||||||
|
get(
|
||||||
|
"https://www.data.gouv.fr/api/1/datasets/r/0ccf4a75-f3aa-4b46-8b6a-18aeb63e36df",
|
||||||
|
follow_redirects=True,
|
||||||
|
)
|
||||||
|
.raise_for_status()
|
||||||
|
.json()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_departements() -> dict:
|
def get_departements() -> dict:
|
||||||
with open("data/departements.json", "rb") as f:
|
with open("data/departements.json", "rb") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|||||||
Reference in New Issue
Block a user