Skip to content

Commit

Permalink
fix(dashboard archiver): remove notifications on bulk dashboard deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
remoterami committed Jan 7, 2025
1 parent 184298c commit 3b2df71
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion backend/pkg/api/data_access/archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/doug-martin/goqu/v9"
t "github.com/gobitfly/beaconchain/pkg/api/types"
"github.com/lib/pq"
)

type ArchiverRepository interface {
Expand Down Expand Up @@ -99,9 +100,23 @@ func (d *DataAccessService) UpdateValidatorDashboardsArchiving(ctx context.Conte
}

func (d *DataAccessService) RemoveValidatorDashboards(ctx context.Context, dashboardIds []uint64) error {
// Delete the dashboard
// Delete the dashboards
_, err := d.writerDb.ExecContext(ctx, `
DELETE FROM users_val_dashboards WHERE id = ANY($1)
`, dashboardIds)
if err != nil {
return err
}

var prefixes []string
for _, dashboardId := range dashboardIds {
prefixes = append(prefixes, fmt.Sprintf("%s:%d:%%", ValidatorDashboardEventPrefix, dashboardId))
}

// Remove all events related to the dashboards
_, err = d.userWriter.ExecContext(ctx, `
DELETE FROM users_subscriptions WHERE event_filter LIKE ANY($1)
`, pq.Array(prefixes))

return err
}

0 comments on commit 3b2df71

Please sign in to comment.