Skip to content

Commit

Permalink
Merge pull request #40 from profcomff/Fix-subject-search
Browse files Browse the repository at this point in the history
Fix subject search
  • Loading branch information
Temmmmmo authored Nov 10, 2024
2 parents f7871a1 + 7d51b6b commit 2da78e9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions rating_api/routes/lecturer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,11 @@ async def get_lecturers(
`name`
Поле для ФИО. Если передано `name` - возвращает всех преподователей, для которых нашлись совпадения с переданной строкой
"""
lecturers = (
Lecturer.query(session=db.session)
.join(Lecturer.comments)
.filter(Lecturer.search_by_name(name))
.filter(Lecturer.search_by_subject(subject))
.all()
)
lecturers_query = Lecturer.query(session=db.session)
if subject:
lecturers_query = lecturers_query.join(Lecturer.comments).filter(Lecturer.search_by_subject(subject))
lecturers_query = lecturers_query.filter(Lecturer.search_by_name(name))
lecturers = lecturers_query.all()
if not lecturers:
raise ObjectNotFound(Lecturer, 'all')
result = LecturerGetAll(limit=limit, offset=offset, total=len(lecturers))
Expand Down

0 comments on commit 2da78e9

Please sign in to comment.