Skip to content

Commit

Permalink
[#136] code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdash committed Sep 4, 2024
1 parent 51614a0 commit 4399426
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dspback/routers/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def is_one_char_off(str1, str2):
return True


async def aggregate_stages(request, stages, pageNumber = 1, pageSize = 30):
async def aggregate_stages(request, stages, pageNumber=1, pageSize=30):
# Insert a `$facet` to extract the total count. We specify pagination here too.
stages.append({ "$facet": {"docs": [{ "$skip": (pageNumber - 1) * pageSize }, { "$limit": pageSize }], "totalCount": [{ "$count": 'count'}]}})
stages.append({"$facet": {"docs": [{"$skip": (pageNumber - 1) * pageSize},
{"$limit": pageSize}], "totalCount": [{"$count": 'count'}]}})

aggregation = await request.app.db[get_settings().mongo_database]["discovery"].aggregate(stages).to_list(pageSize)
total_count = aggregation[0]["totalCount"][0]["count"] if len(aggregation[0]["totalCount"]) else None
Expand Down

0 comments on commit 4399426

Please sign in to comment.