feat(mcp): search_org accepte track=False pour ne pas polluer Matomo
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+5
-2
@@ -5,7 +5,9 @@ from src.utils.table import add_links
|
|||||||
from src.utils.tracking import track_search
|
from src.utils.tracking import track_search
|
||||||
|
|
||||||
|
|
||||||
def search_org(dff: pl.DataFrame, query: str, org_type: str) -> pl.DataFrame:
|
def search_org(
|
||||||
|
dff: pl.DataFrame, query: str, org_type: str, track: bool = True
|
||||||
|
) -> pl.DataFrame:
|
||||||
"""
|
"""
|
||||||
Search in either 'acheteur' or 'titulaire' DataFrame.
|
Search in either 'acheteur' or 'titulaire' DataFrame.
|
||||||
|
|
||||||
@@ -18,7 +20,8 @@ def search_org(dff: pl.DataFrame, query: str, org_type: str) -> pl.DataFrame:
|
|||||||
return dff.select(pl.lit(False).alias("matches"))
|
return dff.select(pl.lit(False).alias("matches"))
|
||||||
|
|
||||||
# Enregistrement des recherche dans Matomo
|
# Enregistrement des recherche dans Matomo
|
||||||
track_search(query, "home_page_search")
|
if track:
|
||||||
|
track_search(query, "home_page_search")
|
||||||
|
|
||||||
# Normalize query
|
# Normalize query
|
||||||
normalized_query = unidecode(query.strip()).upper()
|
normalized_query = unidecode(query.strip()).upper()
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import src.utils.search as search_mod
|
||||||
|
from src.utils.data import DF_ACHETEURS
|
||||||
|
from src.utils.search import search_org
|
||||||
|
|
||||||
|
|
||||||
|
def test_search_org_track_false_skips_track_search(monkeypatch):
|
||||||
|
calls = []
|
||||||
|
monkeypatch.setattr(search_mod, "track_search", lambda q, c: calls.append((q, c)))
|
||||||
|
|
||||||
|
search_org(DF_ACHETEURS, "ACHETEUR", "acheteur", track=False)
|
||||||
|
|
||||||
|
assert calls == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_search_org_track_true_calls_track_search(monkeypatch):
|
||||||
|
calls = []
|
||||||
|
monkeypatch.setattr(search_mod, "track_search", lambda q, c: calls.append((q, c)))
|
||||||
|
|
||||||
|
search_org(DF_ACHETEURS, "ACHETEUR", "acheteur", track=True)
|
||||||
|
|
||||||
|
assert calls == [("ACHETEUR", "home_page_search")]
|
||||||
Reference in New Issue
Block a user