From f3840f18b72f954a19f800c3aff16e5f60e11e56 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Thu, 20 Apr 2023 17:33:19 +0200 Subject: [PATCH] Consider real name when searching (kompetenzinventar/ki-doku#48) --- ki/handlers/find_profiles.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ki/handlers/find_profiles.py b/ki/handlers/find_profiles.py index 1f11967..69a59c9 100644 --- a/ki/handlers/find_profiles.py +++ b/ki/handlers/find_profiles.py @@ -4,7 +4,7 @@ from flask import make_response, request -from ki.models import Profile, ProfileSkill, Skill, ProfileLanguage, Language +from ki.models import Profile, ProfileSkill, Skill, ProfileLanguage, Language, Address def find_profiles(): @@ -25,13 +25,18 @@ def find_profiles(): .order_by(Profile.nickname) \ .filter(Profile.visible.is_(True)) \ .join(Profile.skills, isouter=True).join(ProfileSkill.skill, isouter=True) \ - .join(Profile.languages, isouter=True).join(ProfileLanguage.language, isouter=True) + .join(Profile.languages, isouter=True).join(ProfileLanguage.language, isouter=True) \ + .join(Address, isouter=True) if "search" in request.args: terms = request.args["search"].split(" ") for term in terms: + query = query.filter( - Profile.nickname.like(f"%{term}%") | Skill.name.like(f"%{term}%") | Language.name.like(f"%{term}%")) + Profile.nickname.like(f"%{term}%") | # noqa: W504 + Skill.name.like(f"%{term}%") | # noqa: W504 + Language.name.like(f"%{term}%") | # noqa: W504 + Address.name.like(f"%{term}%")) if "nickname" in request.args: nickname = request.args.get("nickname")