Skip to content

Commit

Permalink
Adjusted cursors
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisei24 committed Oct 31, 2024
1 parent e9a78e3 commit 75459b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions backend/pkg/api/data_access/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,9 @@ func (d *DataAccessService) GetMachineNotifications(ctx context.Context, userId
}

// Sorting and limiting if cursor is present
// Rows can be uniquely identified by (ts, machine_id, event_type)
defaultColumns := []t.SortColumn{
{Column: enums.NotificationsMachinesColumns.Timestamp.ToExpr(), Desc: true, Offset: currentCursor.Epoch},
{Column: enums.NotificationsMachinesColumns.Timestamp.ToExpr(), Desc: true, Offset: currentCursor.Ts},
{Column: enums.NotificationsMachinesColumns.MachineId.ToExpr(), Desc: false, Offset: currentCursor.MachineId},
{Column: enums.NotificationsMachinesColumns.EventType.ToExpr(), Desc: false, Offset: currentCursor.EventType},
}
Expand Down Expand Up @@ -855,9 +856,9 @@ func (d *DataAccessService) GetClientNotifications(ctx context.Context, userId u
}

// Sorting and limiting if cursor is present
// Rows can be uniquely identified by (epoch, client)
// Rows can be uniquely identified by (ts, client)
defaultColumns := []t.SortColumn{
{Column: enums.NotificationsClientsColumns.Timestamp.ToExpr(), Desc: true, Offset: currentCursor.Epoch},
{Column: enums.NotificationsClientsColumns.Timestamp.ToExpr(), Desc: true, Offset: currentCursor.Ts},
{Column: enums.NotificationsClientsColumns.ClientName.ToExpr(), Desc: false, Offset: currentCursor.Client},
}
order, directions := applySortAndPagination(defaultColumns, t.SortColumn{Column: colSort.Column.ToExpr(), Desc: colSort.Desc}, currentCursor.GenericCursor)
Expand Down Expand Up @@ -952,9 +953,9 @@ func (d *DataAccessService) GetNetworkNotifications(ctx context.Context, userId
Limit(uint(limit + 1))

// Sorting and limiting if cursor is present
// Rows can be uniquely identified by (epoch, network, event_type)
// Rows can be uniquely identified by (ts, network, event_type)
defaultColumns := []t.SortColumn{
{Column: enums.NotificationNetworksColumns.Timestamp.ToExpr(), Desc: true, Offset: currentCursor.Epoch},
{Column: enums.NotificationNetworksColumns.Timestamp.ToExpr(), Desc: true, Offset: currentCursor.Ts},
{Column: enums.NotificationNetworksColumns.Network.ToExpr(), Desc: false, Offset: currentCursor.Network},
{Column: enums.NotificationNetworksColumns.EventType.ToExpr(), Desc: false, Offset: currentCursor.EventType},
}
Expand Down
6 changes: 3 additions & 3 deletions backend/pkg/api/types/data_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ type NotificationMachinesCursor struct {
MachineName string
EventType string
EventThreshold float64
Epoch uint64
Ts time.Time
}

type NotificationClientsCursor struct {
GenericCursor

Client string
Epoch uint64
Ts time.Time
}

type NotificationRocketPoolsCursor struct {
Expand All @@ -151,7 +151,7 @@ type NotificationNetworksCursor struct {
GenericCursor

Network uint64
Epoch uint64
Ts time.Time
EventType string
}

Expand Down

0 comments on commit 75459b0

Please sign in to comment.