Use __exact when looking for bugzilla mail

We need to look for exact match when looking for bugzilla mail. This should also
be quicker than normal search.

Signed-off-by: Michal Konečný <mkonecny@redhat.com>
This commit is contained in:
Michal Konečný 2022-08-23 10:49:57 +02:00
parent 109aed5898
commit 869e71ba92
2 changed files with 2 additions and 2 deletions

View file

@ -202,7 +202,7 @@ class TestFedoraAccountFASJSON:
assert output == {"username": "scoady", "rhbzemail": "scoady@fp.o"}
server.search.assert_has_calls(
[call(email="scoady@fp.o"), call(rhbzemail="scoady@fp.o")]
[call(email="scoady@fp.o"), call(rhbzemail__exact="scoady@fp.o")]
)
@patch("toddlers.utils.fedora_account.get_fasjson")

View file

@ -101,7 +101,7 @@ def get_user_by_email(email: str) -> Optional[dict]:
result = fasjson.search(email=email).result or []
if not result:
# Try the bugzilla email as well
result = fasjson.search(rhbzemail=email).result or []
result = fasjson.search(rhbzemail__exact=email).result or []
if result:
user = result[0]
except ClientError: