Skip to content

Commit

Permalink
fix(study-search): update pagination query regarding joins on groups …
Browse files Browse the repository at this point in the history
…and tags
  • Loading branch information
mabw-rte committed Mar 26, 2024
1 parent 9e971f4 commit bfc96f0
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 @@ -257,9 +257,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 @@ -305,12 +313,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 bfc96f0

Please sign in to comment.