Skip to content

Commit 1b43d52

Browse files
committed
Sort email outbox by createdAt
1 parent 343cb45 commit 1b43d52

2 files changed

Lines changed: 1 addition & 10 deletions

File tree

apps/backend/prisma/schema.prisma

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,6 @@ enum EmailOutboxCreatedWith {
704704
PROGRAMMATIC_CALL
705705
}
706706

707-
// In most displays, the way emails in the outbox should be ordered is:
708-
// - by finishedSendingAt, descending (null comes first)
709-
// - by scheduledAtIfNotYetQueued, descending (null comes last)
710-
// - by priority, ascending
711-
// - by id, ascending
712707
model EmailOutbox {
713708
tenancyId String @db.Uuid
714709

apps/backend/src/app/api/latest/emails/outbox/crud.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,7 @@ export const emailOutboxCrudHandlers = createLazyProxy(() => createCrudHandlers(
317317
const emails = await globalPrismaClient.emailOutbox.findMany({
318318
where,
319319
orderBy: [
320-
// Emails with finishedSendingAt come first (most recent first), then nulls
321-
{ finishedSendingAt: { sort: "desc", nulls: "last" } },
322-
// For not-yet-sent emails: scheduled ones come first (most recent first), then nulls
323-
{ scheduledAtIfNotYetQueued: { sort: "desc", nulls: "last" } },
324-
{ priority: "asc" },
320+
{ createdAt: "desc" },
325321
{ id: "asc" },
326322
],
327323
// +1 to check if there's a next page

0 commit comments

Comments
 (0)