aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"