Réarrangements résultats #58
This commit is contained in:
+12
-5
@@ -146,7 +146,7 @@ td[data-dash-column="objet"],td[data-dash-column="titulaire_nom"],td[data-dash-c
|
|||||||
/* Page de recherche */
|
/* Page de recherche */
|
||||||
|
|
||||||
#search {
|
#search {
|
||||||
margin: auto;
|
margin: 50px auto 0px auto;
|
||||||
width: 450px;
|
width: 450px;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
@@ -162,6 +162,16 @@ td[data-dash-column="objet"],td[data-dash-column="titulaire_nom"],td[data-dash-c
|
|||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.results_acheteur {
|
||||||
|
grid-column: 1;
|
||||||
|
grid-row: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results_titulaire {
|
||||||
|
grid-column: 2;
|
||||||
|
grid-row: 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Menu de navigation */
|
/* Menu de navigation */
|
||||||
|
|
||||||
.navbar {
|
.navbar {
|
||||||
@@ -191,7 +201,7 @@ summary > h3 {
|
|||||||
padding-top: 28px;
|
padding-top: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vue acheteur/titulaire */
|
/* Vue acheteur/titulaire/recherche */
|
||||||
.wrapper {
|
.wrapper {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
@@ -199,9 +209,6 @@ summary > h3 {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wrapper > div {
|
|
||||||
}
|
|
||||||
|
|
||||||
.org_title {
|
.org_title {
|
||||||
grid-column: 1 / 3;
|
grid-column: 1 / 3;
|
||||||
grid-row: 1;
|
grid-row: 1;
|
||||||
|
|||||||
+32
-8
@@ -32,7 +32,7 @@ layout = html.Div(
|
|||||||
# className="search_options",
|
# className="search_options",
|
||||||
# children=[dcc.RadioItems(options=["Acheteur(s)"])],
|
# children=[dcc.RadioItems(options=["Acheteur(s)"])],
|
||||||
# ),
|
# ),
|
||||||
html.Div(id="search_results"),
|
html.Div(id="search_results", className="wrapper"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -62,13 +62,37 @@ def update_search_results(query):
|
|||||||
columns, tooltip = setup_table_columns(results, hideable=False)
|
columns, tooltip = setup_table_columns(results, hideable=False)
|
||||||
|
|
||||||
org_content = [
|
org_content = [
|
||||||
html.H3(f"{org_type.title()}s : {count}"),
|
html.Div(
|
||||||
dash_table.DataTable(
|
className=f"results_{org_type}",
|
||||||
columns=columns,
|
children=[
|
||||||
data=results.to_dicts(),
|
html.H3(f"{org_type.title()}s : {count}"),
|
||||||
page_size=5,
|
dash_table.DataTable(
|
||||||
style_table={"overflowX": "auto"},
|
columns=columns,
|
||||||
markdown_options={"html": True},
|
data=results.to_dicts(),
|
||||||
|
page_size=10,
|
||||||
|
# style_table={"overflowX": "auto"},
|
||||||
|
markdown_options={"html": True},
|
||||||
|
cell_selectable=False,
|
||||||
|
style_cell_conditional=[
|
||||||
|
{
|
||||||
|
"if": {"column_id": "acheteur_nom"},
|
||||||
|
"maxWidth": "250px",
|
||||||
|
"textAlign": "left",
|
||||||
|
"overflow": "hidden",
|
||||||
|
"lineHeight": "18px",
|
||||||
|
"whiteSpace": "normal",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": {"column_id": "titulaire_nom"},
|
||||||
|
"maxWidth": "250px",
|
||||||
|
"textAlign": "left",
|
||||||
|
"overflow": "hidden",
|
||||||
|
"lineHeight": "18px",
|
||||||
|
"whiteSpace": "normal",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
if count > 0
|
if count > 0
|
||||||
else html.P(f"Aucun {org_type} trouvé."),
|
else html.P(f"Aucun {org_type} trouvé."),
|
||||||
|
|||||||
+7
-6
@@ -234,7 +234,7 @@ def get_org_data(dff: pl.DataFrame, org_type: str) -> pl.DataFrame:
|
|||||||
f"{org_type}_latitude", f"{org_type}_longitude"
|
f"{org_type}_latitude", f"{org_type}_longitude"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
lff = lff.group_by(cs.starts_with(org_type)).len("len_uid")
|
lff = lff.group_by(cs.starts_with(org_type)).len("Marchés")
|
||||||
return lff.collect()
|
return lff.collect()
|
||||||
|
|
||||||
|
|
||||||
@@ -406,10 +406,11 @@ def search_org(dff: pl.DataFrame, query: str, org_type: str) -> pl.DataFrame:
|
|||||||
if not query.strip():
|
if not query.strip():
|
||||||
return dff.select(pl.lit(False).alias("matches"))
|
return dff.select(pl.lit(False).alias("matches"))
|
||||||
|
|
||||||
|
sleep(0.2)
|
||||||
|
|
||||||
# Normalize query
|
# Normalize query
|
||||||
normalized_query = unidecode(query.strip()).upper()
|
normalized_query = unidecode(query.strip()).upper()
|
||||||
tokens = [" " + t.strip() for t in normalized_query.split() if t.strip()]
|
tokens = [" " + t.strip() for t in normalized_query.split() if t.strip()]
|
||||||
print(tokens)
|
|
||||||
|
|
||||||
# Define columns based on entity type
|
# Define columns based on entity type
|
||||||
cols = [
|
cols = [
|
||||||
@@ -440,15 +441,15 @@ def search_org(dff: pl.DataFrame, query: str, org_type: str) -> pl.DataFrame:
|
|||||||
|
|
||||||
# Sélection des colonnes
|
# Sélection des colonnes
|
||||||
if org_type == "acheteur":
|
if org_type == "acheteur":
|
||||||
dff = dff.select(cols + ["len_uid"])
|
dff = dff.select(cols + ["Marchés"])
|
||||||
if org_type == "titulaire":
|
if org_type == "titulaire":
|
||||||
dff = dff.select(cols + ["len_uid", "titulaire_typeIdentifiant"])
|
dff = dff.select(cols + ["Marchés", "titulaire_typeIdentifiant"])
|
||||||
|
|
||||||
# Apply and filter
|
# Apply and filter
|
||||||
dff = (
|
dff = (
|
||||||
dff.with_columns(token_matches + [match_score])
|
dff.with_columns(token_matches + [match_score])
|
||||||
.filter(pl.col("match_score") == len(tokens))
|
.filter(pl.col("match_score") == len(tokens))
|
||||||
.sort("len_uid", descending=True)
|
.sort("Marchés", descending=True)
|
||||||
.drop([f"token_{token}" for token in tokens])
|
.drop([f"token_{token}" for token in tokens])
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -463,7 +464,7 @@ def search_org(dff: pl.DataFrame, query: str, org_type: str) -> pl.DataFrame:
|
|||||||
).alias("Département")
|
).alias("Département")
|
||||||
)
|
)
|
||||||
|
|
||||||
dff = dff.select(f"{org_type}_id", f"{org_type}_nom", "Département")
|
dff = dff.select(f"{org_type}_id", f"{org_type}_nom", "Département", "Marchés")
|
||||||
|
|
||||||
return dff
|
return dff
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user