Skip to content

Commit

Permalink
Merge branch 'staging' into BEDS-397/initialize_efficiency_map
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbitfly committed Oct 31, 2024
2 parents 6f52db8 + a5628cc commit 3f1a5fa
Show file tree
Hide file tree
Showing 31 changed files with 625 additions and 679 deletions.
2 changes: 1 addition & 1 deletion backend/pkg/api/data_access/archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (d *DataAccessService) UpdateValidatorDashboardsArchiving(ctx context.Conte

query, args, err := ds.Prepared(true).ToSQL()
if err != nil {
return fmt.Errorf("error preparing query: %v", err)
return fmt.Errorf("error preparing query: %w", err)
}

_, err = d.writerDb.ExecContext(ctx, query, args...)
Expand Down
3 changes: 0 additions & 3 deletions backend/pkg/api/data_access/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,6 @@ func (d *DummyService) GetMachineNotifications(ctx context.Context, userId uint6
func (d *DummyService) GetClientNotifications(ctx context.Context, userId uint64, cursor string, colSort t.Sort[enums.NotificationClientsColumn], search string, limit uint64) ([]t.NotificationClientsTableRow, *t.Paging, error) {
return getDummyWithPaging[t.NotificationClientsTableRow](ctx)
}
func (d *DummyService) GetRocketPoolNotifications(ctx context.Context, userId uint64, cursor string, colSort t.Sort[enums.NotificationRocketPoolColumn], search string, limit uint64) ([]t.NotificationRocketPoolTableRow, *t.Paging, error) {
return getDummyWithPaging[t.NotificationRocketPoolTableRow](ctx)
}
func (d *DummyService) GetNetworkNotifications(ctx context.Context, userId uint64, cursor string, colSort t.Sort[enums.NotificationNetworksColumn], limit uint64) ([]t.NotificationNetworksTableRow, *t.Paging, error) {
return getDummyWithPaging[t.NotificationNetworksTableRow](ctx)
}
Expand Down
18 changes: 12 additions & 6 deletions backend/pkg/api/data_access/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func applySortAndPagination(defaultColumns []types.SortColumn, primary types.Sor
if cursor.IsReverse() {
column.Desc = !column.Desc
}
colOrder := goqu.C(column.Column).Asc()
colOrder := column.Column.Asc().NullsFirst()
if column.Desc {
colOrder = goqu.C(column.Column).Desc()
colOrder = column.Column.Desc().NullsLast()
}
queryOrder = append(queryOrder, colOrder)
}
Expand All @@ -87,15 +87,21 @@ func applySortAndPagination(defaultColumns []types.SortColumn, primary types.Sor
// reverse order to nest conditions
for i := len(queryOrderColumns) - 1; i >= 0; i-- {
column := queryOrderColumns[i]
colWhere := goqu.C(column.Column).Gt(column.Offset)
if column.Desc {
colWhere = goqu.C(column.Column).Lt(column.Offset)
var colWhere exp.Expression

// current convention is opposite of the psql default (ASC: nulls first, DESC: nulls last)
colWhere = goqu.Or(column.Column.Lt(column.Offset), column.Column.IsNull())
if !column.Desc {
colWhere = column.Column.Gt(column.Offset)
if column.Offset == nil {
colWhere = goqu.Or(colWhere, column.Column.IsNull())
}
}

if queryWhere == nil {
queryWhere = colWhere
} else {
queryWhere = goqu.And(goqu.C(column.Column).Eq(column.Offset), queryWhere)
queryWhere = goqu.And(column.Column.Eq(column.Offset), queryWhere)
queryWhere = goqu.Or(colWhere, queryWhere)
}
}
Expand Down
270 changes: 43 additions & 227 deletions backend/pkg/api/data_access/notifications.go

Large diffs are not rendered by default.

Loading

0 comments on commit 3f1a5fa

Please sign in to comment.