Skip to content

Commit

Permalink
Revert "Improve notices endpoint"
Browse files Browse the repository at this point in the history
  • Loading branch information
samhotep authored Jun 18, 2024
1 parent 54969d3 commit 985cbbe
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion webapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ 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 @@ -436,6 +437,8 @@ def get_notices(**kwargs):
)
)

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

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

0 comments on commit 985cbbe

Please sign in to comment.