Skip to content

Commit

Permalink
fix backend lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrieuclp committed Dec 23, 2024
1 parent 6751cc1 commit 8bcdb4b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/geonature/core/gn_meta/models/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,20 @@ class DatasetFilterSchema(MetadataFilterSchema):

search = params.get("search")
if search:
#si uniquement des chiffres (chercher dans ID ou name)
# si uniquement des chiffres (chercher dans ID ou name)
if search.isdigit():
ors = [
func.unaccent(cls.dataset_name).ilike(func.unaccent(f"%{search}%")),
sa.cast(cls.id_dataset, sa.String) == search,
]
else:
#sinon découpe sur les espaces pour rechercher dans le nom
# sinon découpe sur les espaces pour rechercher dans le nom
ands = [];
for term in search.split(" "):
if len(term) > 0:
ands.append(func.unaccent(cls.dataset_name).ilike(func.unaccent(f"%{term}%")))
ands.append(
func.unaccent(cls.dataset_name).ilike(func.unaccent(f"%{term}%"))
)
ors = [sa.and_(*ands)]
# enable uuid search only with at least 5 characters
if len(search) >= 5:
Expand Down

0 comments on commit 8bcdb4b

Please sign in to comment.