Skip to content

Commit

Permalink
Merge pull request #146 from canonical/improve-request-performance
Browse files Browse the repository at this point in the history
Improve notices endpoint
  • Loading branch information
samhotep authored Jun 13, 2024
2 parents 04ecd21 + 6b7c018 commit 54969d3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions webapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ def get_notices(**kwargs):
release = kwargs.get("release")
limit = kwargs.get("limit", 20)
offset = kwargs.get("offset", 0)
order_by = kwargs.get("order")

notices_query: Query = db.session.query(Notice)

Expand All @@ -437,8 +436,6 @@ def get_notices(**kwargs):
)
)

sort = asc if order_by == "oldest" else desc

notices = (
notices_query.options(
selectinload(Notice.cves).options(
Expand All @@ -451,7 +448,7 @@ def get_notices(**kwargs):
)
)
.options(selectinload(Notice.releases))
.order_by(sort(Notice.published), sort(Notice.id))
.order_by(Notice.published, Notice.id)
.offset(offset)
.limit(limit)
.all()
Expand Down

0 comments on commit 54969d3

Please sign in to comment.