Skip to content

Commit 76de7d5

Browse files
committed
fix(backend/api/services): enhance job listing with created_at sorting
1 parent fbd39a4 commit 76de7d5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

backend/api/services/dynamo_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def list_jobs(
129129
limit: int = 20,
130130
last_evaluated_key: Optional[Dict] = None
131131
) -> tuple[List[Dict], Optional[Dict]]:
132-
"""List training jobs for a user with pagination"""
132+
"""List training jobs for a user with pagination, ordered by created_at DESC"""
133133
try:
134134
scan_kwargs = {
135135
'Limit': limit,
@@ -144,6 +144,9 @@ def list_jobs(
144144
items = self._convert_decimals(response.get('Items', []))
145145
next_key = response.get('LastEvaluatedKey')
146146

147+
# Sort by created_at descending (newest first)
148+
items.sort(key=lambda x: x.get('created_at', ''), reverse=True)
149+
147150
return items, next_key
148151
except ClientError as e:
149152
raise Exception(f"Error listing jobs: {str(e)}")

0 commit comments

Comments
 (0)