aboutsummaryrefslogtreecommitdiff
path: root/app/routes
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-11-08 15:07:11 -0600
committerParker <contact@pkrm.dev>2024-11-08 15:07:11 -0600
commitc13c9ebbbb0e28619a44aa4829b15ee08fce819c (patch)
treeb46242dcdc48fcfd184bf06a93217e93bee3fe74 /app/routes
parentf1411191b001bd35af83dda869ce492ff8f88899 (diff)
Order links by date descending when returned
Diffstat (limited to 'app/routes')
-rw-r--r--app/routes/links_routes.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/routes/links_routes.py b/app/routes/links_routes.py
index f56ebfc..833c699 100644
--- a/app/routes/links_routes.py
+++ b/app/routes/links_routes.py
@@ -21,7 +21,13 @@ async def get_links(
current_user: Annotated[User, Depends(get_current_user)],
db=Depends(get_db),
):
- links = db.query(Link).filter(Link.owner == current_user.id).all()
+ # Get and sort links by expiration date descending
+ links = (
+ db.query(Link)
+ .filter(Link.owner == current_user.id)
+ .order_by(Link.expire_date.desc())
+ .all()
+ )
if not links:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail="No links found"