Skip to content

Commit

Permalink
Clarify that page is an iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Sep 5, 2024
1 parent 49866ab commit 89ef29f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions arches_lingo/views/api/concepts.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@ def get(self, request):
concept_ids = concept_query.values_list("concept_id", flat=True).distinct()

paginator = Paginator(concept_ids, items_per_page)
page = paginator.get_page(page_number)

data = []
if not page:
# No results: don't bother building the concept tree.
return JSONResponse(data)
if not paginator.count:
return JSONResponse([])

builder = ConceptBuilder()
data = [
builder.serialize_concept(str(concept_uuid), parents=True, children=False)
for concept_uuid in page
for concept_uuid in paginator.get_page(page_number)
]

return JSONResponse(data)
Expand Down

0 comments on commit 89ef29f

Please sign in to comment.