Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(study-search): correct pagination SQL query #1988

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions antarest/study/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,17 @@ def get_all(

# pagination
if pagination.page_nb or pagination.page_size:
q = q.offset(pagination.page_nb * pagination.page_size).limit(pagination.page_size)

studies: t.Sequence[Study] = q.all()
limit = pagination.page_size
offset = pagination.page_nb * pagination.page_size
end = offset + limit
if sort_by is None:
q = q.order_by(entity.name.asc())
if study_filter.groups or study_filter.tags:
studies: t.Sequence[Study] = q.all()[offset:end]
return studies
q = q.offset(offset).limit(limit)

studies = q.all()
return studies

def count_studies(self, study_filter: StudyFilter = StudyFilter()) -> int:
Expand Down Expand Up @@ -303,12 +311,9 @@ def _search_studies(
else:
q = q.filter(not_(RawStudy.missing.is_(None)))

if study_filter.users is not None:
q = q.options(joinedload(entity.owner))
if study_filter.groups is not None:
q = q.options(joinedload(entity.groups))
if study_filter.tags is not None:
q = q.options(joinedload(entity.tags))
q = q.options(joinedload(entity.owner))
q = q.options(joinedload(entity.groups))
q = q.options(joinedload(entity.tags))
q = q.options(joinedload(entity.additional_data))

if study_filter.managed is not None:
Expand Down
Loading
Loading