♻️ sort by pending first

This commit is contained in:
Fred KISSIE
2026-01-14 00:37:48 +01:00
parent dd5ca10226
commit 30943010e6

View File

@@ -68,7 +68,10 @@ async function queryApprovals(orgId: string, limit: number, offset: number) {
)
)
.where(eq(approvals.orgId, orgId))
.orderBy(desc(approvals.timestamp))
.orderBy(
sql`CASE ${approvals.decision} WHEN 'pending' THEN 0 ELSE 1 END`,
desc(approvals.timestamp)
)
.limit(limit)
.offset(offset);
return res;