diff --git a/src/pages/acheteur.py b/src/pages/acheteur.py index 58e61db..d51646b 100644 --- a/src/pages/acheteur.py +++ b/src/pages/acheteur.py @@ -35,6 +35,7 @@ from src.utils.table import ( prepare_table_data, sort_table_data, ) +from src.utils.tracking import track_search def get_title(acheteur_id: str | None = None) -> str: @@ -424,6 +425,7 @@ def download_filtered_acheteur_data( lff = lff.drop(hidden_columns) if filter_query: + track_search(filter_query, "ach download") lff = filter_table_data(lff, filter_query, "ach download") if len(sort_by) > 0: diff --git a/src/pages/tableau.py b/src/pages/tableau.py index 723db62..4c30ac3 100644 --- a/src/pages/tableau.py +++ b/src/pages/tableau.py @@ -31,6 +31,7 @@ from src.utils.table import ( prepare_table_data, sort_table_data, ) +from src.utils.tracking import track_search update_date_timestamp = os.path.getmtime(os.getenv("DATA_FILE_PARQUET_PATH")) update_date = datetime.fromtimestamp(update_date_timestamp).strftime("%d/%m/%Y") @@ -322,6 +323,7 @@ def download_data(n_clicks, filter_query, sort_by, hidden_columns: list = None): lff = lff.drop(hidden_columns) if filter_query: + track_search(filter_query, "tab download") lff = filter_table_data(lff, filter_query, "tab download") if sort_by and len(sort_by) > 0: diff --git a/src/pages/titulaire.py b/src/pages/titulaire.py index 3347c19..32f71d5 100644 --- a/src/pages/titulaire.py +++ b/src/pages/titulaire.py @@ -34,6 +34,7 @@ from src.utils.table import ( prepare_table_data, sort_table_data, ) +from src.utils.tracking import track_search def get_title(titulaire_id: str = None) -> str: @@ -440,6 +441,7 @@ def download_filtered_titulaire_data( lff = lff.drop(hidden_columns) if filter_query: + track_search(filter_query, "titu download") lff = filter_table_data(lff, filter_query, "titu download") if len(sort_by) > 0: diff --git a/src/utils/table.py b/src/utils/table.py index a0814f7..e0f20fd 100644 --- a/src/utils/table.py +++ b/src/utils/table.py @@ -9,7 +9,6 @@ from src.db import query_marches, schema from src.utils import logger from src.utils.data import DATA_SCHEMA from src.utils.frontend import get_button_properties -from src.utils.tracking import track_search def split_filter_part(filter_part): @@ -210,7 +209,6 @@ def filter_table_data( lff: pl.LazyFrame, filter_query: str, filter_source: str ) -> pl.LazyFrame: _schema = lff.collect_schema() - track_search(filter_query, filter_source) filtering_expressions = filter_query.split(" && ") for filter_part in filtering_expressions: col_name, operator, filter_value = split_filter_part(filter_part) diff --git a/tests/test_table.py b/tests/test_table.py index 8e08e44..aced802 100644 --- a/tests/test_table.py +++ b/tests/test_table.py @@ -30,3 +30,17 @@ def test_table_module_imports(): from src.utils import table assert hasattr(table, "prepare_table_data") + + +def test_filter_table_data_does_not_call_track_search(monkeypatch, sample_lff): + from src.utils import table + + calls = [] + monkeypatch.setattr(table, "track_search", lambda *a, **kw: calls.append(a)) + + result = table.filter_table_data( + sample_lff, "{objet} icontains travaux", "tableau" + ).collect() + + assert calls == [] + assert result.height == 1