Skip to content

Commit

Permalink
Minor notification fix on account export
Browse files Browse the repository at this point in the history
  • Loading branch information
sesposito committed Nov 20, 2024
1 parent b4b60a9 commit a69272a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions server/core_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,17 @@ func NotificationList(ctx context.Context, logger *zap.Logger, db *sql.DB, userI

cursorQuery := ""
if nc != nil && nc.NotificationID != nil {
cursorQuery = " AND (create_time, id) > ($3::TIMESTAMPTZ, $4::UUID)"
cursorQuery = " AND (user_id, create_time, id) > ($1::UUID, $3::TIMESTAMPTZ, $4::UUID)"
params = append(params, &pgtype.Timestamptz{Time: time.Unix(0, nc.CreateTime).UTC(), Valid: true}, uuid.FromBytesOrNil(nc.NotificationID))
}

rows, err := db.QueryContext(ctx, `
query := `
SELECT id, subject, content, code, sender_id, create_time
FROM notification
WHERE user_id = $1`+cursorQuery+`
ORDER BY create_time ASC, id ASC`+limitQuery, params...)
WHERE user_id = $1` + cursorQuery + `
ORDER BY create_time ASC, id ASC` + limitQuery

rows, err := db.QueryContext(ctx, query, params...)
if err != nil {
logger.Error("Could not retrieve notifications.", zap.Error(err))
return nil, err
Expand All @@ -247,7 +248,7 @@ ORDER BY create_time ASC, id ASC`+limitQuery, params...)
var hasNextPage bool
for rows.Next() {
resultCount++
if resultCount > limit {
if limit > 0 && resultCount > limit {
hasNextPage = true
break
}
Expand Down

0 comments on commit a69272a

Please sign in to comment.