Skip to content

Commit

Permalink
update joins and where for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
WillCorrigan committed Nov 5, 2024
1 parent 48cfc4b commit 91706ac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/frontpage/lib/data/db/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@ export const getNotifications = cache(
.from(schema.Notification)
.where(
and(
eq(schema.Comment.status, "live"),
eq(schema.Notification.did, user.did),
cursor
? lt(schema.Notification.createdAt, cursorToDate(cursor))
: undefined,
),
)
.leftJoin(
.innerJoin(
schema.Comment,
eq(schema.Comment.id, schema.Notification.commentId),
)
.leftJoin(schema.Post, eq(schema.Post.id, schema.Comment.postId))
.innerJoin(schema.Post, eq(schema.Post.id, schema.Comment.postId))
.groupBy(schema.Notification.id)
.orderBy(desc(schema.Notification.id))
.limit(limit);
Expand Down

0 comments on commit 91706ac

Please sign in to comment.