Skip to content

Commit 3b2df71

Browse files
committed
fix(dashboard archiver): remove notifications on bulk dashboard deletion
1 parent 184298c commit 3b2df71

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

backend/pkg/api/data_access/archiver.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/doug-martin/goqu/v9"
99
t "github.com/gobitfly/beaconchain/pkg/api/types"
10+
"github.com/lib/pq"
1011
)
1112

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

101102
func (d *DataAccessService) RemoveValidatorDashboards(ctx context.Context, dashboardIds []uint64) error {
102-
// Delete the dashboard
103+
// Delete the dashboards
103104
_, err := d.writerDb.ExecContext(ctx, `
104105
DELETE FROM users_val_dashboards WHERE id = ANY($1)
105106
`, dashboardIds)
107+
if err != nil {
108+
return err
109+
}
110+
111+
var prefixes []string
112+
for _, dashboardId := range dashboardIds {
113+
prefixes = append(prefixes, fmt.Sprintf("%s:%d:%%", ValidatorDashboardEventPrefix, dashboardId))
114+
}
115+
116+
// Remove all events related to the dashboards
117+
_, err = d.userWriter.ExecContext(ctx, `
118+
DELETE FROM users_subscriptions WHERE event_filter LIKE ANY($1)
119+
`, pq.Array(prefixes))
120+
106121
return err
107122
}

0 commit comments

Comments
 (0)