diff --git a/app/clients/db_client.py b/app/clients/db_client.py
index 48072a7..b934ead 100644
--- a/app/clients/db_client.py
+++ b/app/clients/db_client.py
@@ -1,5 +1,5 @@
from dataclasses import dataclass
-from typing import Type
+from typing import Type, List
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
@@ -49,14 +49,14 @@ def __init__(self, app: Flask, session: Session = db.session):
github_username='test_user_3_github_username'))
self.__session.commit()
- def get_user_by_email(self, email: str) -> Type[UserModel] | None:
- return self.__session.query(UserModel).filter_by(email=email).first()
+ def get_user_by_email(self, email: str) -> List[Type[UserModel]] | None:
+ return self.__session.query(UserModel).filter(UserModel.email.ilike(f"%{email}%")).all()
- def get_user_by_slack_username(self, slack_username: str) -> Type[UserModel] | None:
- return self.__session.query(UserModel).filter_by(slack_username=slack_username).first()
+ def get_user_by_slack_username(self, slack_username: str) -> List[Type[UserModel]] | None:
+ return self.__session.query(UserModel).filter(UserModel.slack_username.ilike(f"%{slack_username}%")).all()
- def get_user_by_github_username(self, github_username: str) -> Type[UserModel] | None:
- return self.__session.query(UserModel).filter_by(github_username=github_username).first()
+ def get_user_by_github_username(self, github_username: str) -> List[Type[UserModel]] | None:
+ return self.__session.query(UserModel).filter(UserModel.github_username.ilike(f"%{github_username}%")).all()
def add_users(self, users: list[dict], allowed_users: list[str]):
for user in users:
diff --git a/app/routes/views.py b/app/routes/views.py
index ef30371..518bc1e 100644
--- a/app/routes/views.py
+++ b/app/routes/views.py
@@ -20,17 +20,17 @@ def user_search():
email_results = user_service.get_user_by_email(user_query)
- if email_results is not None:
+ if email_results:
return render_template('search-results.html', results=email_results, user_query=user_query)
slack_results = user_service.get_user_by_slack_username(user_query)
- if slack_results is not None:
+ if slack_results:
return render_template('search-results.html', results=slack_results, user_query=user_query)
github_results = user_service.get_user_by_github_username(user_query)
- if github_results is not None:
+ if github_results:
return render_template('search-results.html', results=github_results, user_query=user_query)
return render_template('search-results.html', results=None, user_query=user_query)
diff --git a/app/templates/home.html b/app/templates/home.html
index d2f0c78..cef6224 100644
--- a/app/templates/home.html
+++ b/app/templates/home.html
@@ -9,7 +9,7 @@
Ministry of Justice User Search
Overview
- This website enabled users to cross reference email, Slack usernames and GitHub usernames to identify user information from one source to another.
+ This website enables users to cross reference email, Slack usernames and GitHub usernames to identify user information from one source to another.