Pārlūkot izejas kodu

Fixed user search

main
Madiwka pirms 1 gada
vecāks
revīzija
cd9397bfa1
1 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  1. +4
    -1
      app/db/repository/user.py

+ 4
- 1
app/db/repository/user.py Parādīt failu

@@ -131,7 +131,10 @@ def delete_user_data(id: int, db: Session):
def user_search_query(
db: Session, name: str = "", role: str = None, page: int = 1, per_page: int = 20
):
query = db.query(User).filter(User.Name.like(f"{name}%"))
if name == "" or name is None:
query = db.query(User)
else:
query = db.query(User).filter(User.Name.like(f"{name}%"))
if role is not None and role != "Admin":
query = query.filter(User.Role == role)
total_users = query.count()


Notiek ielāde…
Atcelt
Saglabāt