diff --git a/README.md b/README.md index 02ee76e..ba10c99 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Outil d'exploration et de téléchargement des données essentielles de la comma python -m venv .venv source .venv/bin/activate pip install . -python src/app.py +gunicorn app:server ``` ## Dépôts de code connexes diff --git a/src/app.py b/app.py similarity index 58% rename from src/app.py rename to app.py index 5f77277..ebe018f 100644 --- a/src/app.py +++ b/app.py @@ -1,14 +1,20 @@ from dash import Dash, html, dcc, callback, Output, Input, dash_table import plotly.express as px import polars as pl +import dash_bootstrap_components as dbc -df = pl.read_parquet( - "https://www.data.gouv.fr/fr/datasets/r/11cea8e8-df3e-4ed1-932b-781e2635e432" -) +df = pl.read_ipc("/home/colin/git/decp-processing/dist/decp.arrow") -app = Dash() +app = Dash(external_stylesheets=[dbc.themes.UNITED]) +server = app.server app.layout = [ + html.Div( + [ + "Recherche (acheteur, titulaire, objet) : ", + dcc.Input(id="search", value="", type="text"), + ] + ), html.H1(children="decp.info", style={"textAlign": "center"}), dash_table.DataTable( id="table", @@ -29,6 +35,17 @@ app.layout = [ ] +@callback( + Output(component_id="table", component_property="data", allow_duplicate=True), + Input(component_id="search", component_property="value"), + prevent_initial_call=True, +) +def global_search(text): + new_df = df + new_df = new_df.filter(pl.col("objet").str.contains("(?i)" + text)) + return new_df.to_dicts() + + @callback( Output("table", "data"), Input("table", "page_current"), Input("table", "page_size") ) diff --git a/pyproject.toml b/pyproject.toml index 86fb930..0640f72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,8 @@ authors = [ ] dependencies = [ "dash", - "polars" + "polars", + "gunicorn" ] [project.optional-dependencies]