Skip to content

Commit

Permalink
Merge pull request #1043 from gobitfly/BEDS-890/handle-group-efficien…
Browse files Browse the repository at this point in the history
…cy-event

(BEDS-8909) DA: dashboard notifications handle group efficiency
  • Loading branch information
remoterami authored Oct 29, 2024
2 parents d4b309c + d078cab commit 9f5176f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions backend/pkg/api/data_access/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,12 @@ func (d *DataAccessService) GetValidatorDashboardNotificationDetails(ctx context

for _, notification := range notifications {
switch notification.GetEventName() {
case types.ValidatorGroupEfficiencyEventName:
curNotification, ok := notification.(*n.ValidatorGroupEfficiencyNotification)
if !ok {
return nil, fmt.Errorf("failed to cast notification to ValidatorGroupEfficiencyNotification")
}
notificationDetails.GroupEfficiencyBelow = curNotification.Threshold
case types.ValidatorMissedProposalEventName, types.ValidatorExecutedProposalEventName /*, types.ValidatorScheduledProposalEventName*/ :
// aggregate proposals
curNotification, ok := notification.(*n.ValidatorProposalNotification)
Expand Down Expand Up @@ -613,8 +619,12 @@ func (d *DataAccessService) GetValidatorDashboardNotificationDetails(ctx context
if !ok {
return nil, fmt.Errorf("failed to cast notification to RocketpoolNotification")
}
addr := t.Address{Hash: t.Hash(notification.GetEventFilter()), IsContract: true}
addressMapping[notification.GetEventFilter()] = &addr
nodeAddress := notification.GetEventFilter()
if nodeAddress == "" {
return nil, fmt.Errorf("empty node address in Rocket Pool collateral notification: dashboardId '%d', epoch '%d'", dashboardId, epoch)
}
addr := t.Address{Hash: t.Hash(nodeAddress), IsContract: true}
addressMapping[nodeAddress] = &addr
if notification.GetEventName() == types.RocketpoolCollateralMinReachedEventName {
notificationDetails.MinimumCollateralReached = append(notificationDetails.MinimumCollateralReached, addr)
} else {
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/notification/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func collectGroupEfficiencyNotifications(notificationsByUserID types.Notificatio
DashboardGroupId: groupDetails.Subscription.DashboardGroupId,
DashboardGroupName: groupDetails.Subscription.DashboardGroupName,
},
Threshold: groupDetails.Subscription.EventThreshold * 100,
Threshold: groupDetails.Subscription.EventThreshold,
Efficiency: efficiency,
}
notificationsByUserID.AddNotification(n)
Expand Down
2 changes: 1 addition & 1 deletion backend/pkg/notification/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (n *ValidatorGroupEfficiencyNotification) GetEntitiyId() string {
func (n *ValidatorGroupEfficiencyNotification) GetInfo(format types.NotificationFormat) string {
dashboardAndGroupInfo := formatPureDashboardAndGroupLink(format, n)
epoch := formatEpochLink(format, n.Epoch)
return fmt.Sprintf(`%s efficiency of %.2f%% was below the threhold of %.2f%% in epoch %s.`, dashboardAndGroupInfo, n.Efficiency, n.Threshold, epoch)
return fmt.Sprintf(`%s efficiency of %.2f%% was below the threshold of %.2f%% in epoch %s.`, dashboardAndGroupInfo, n.Efficiency, n.Threshold, epoch)
}

func (n *ValidatorGroupEfficiencyNotification) GetTitle() string {
Expand Down

0 comments on commit 9f5176f

Please sign in to comment.