Skip to content

Commit

Permalink
fix(study-search): correct pagination SQL query (#1988)
Browse files Browse the repository at this point in the history
fix(study-search): correct pagination SQL query (#1988)
  • Loading branch information
laurent-laporte-pro authored Apr 9, 2024
2 parents bf6813e + 0d38640 commit 9140fe3
Show file tree
Hide file tree
Showing 3 changed files with 408 additions and 386 deletions.
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

0 comments on commit 9140fe3

Please sign in to comment.