Skip to content

Commit

Permalink
Merge pull request #1102 from gobitfly/BEDS-933/Event_type_should_not…
Browse files Browse the repository at this point in the history
…_be_converted

Removed the event type conversion
  • Loading branch information
Eisei24 authored Nov 6, 2024
2 parents 521bc8f + c86c2d4 commit 6233664
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions backend/pkg/api/data_access/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,24 +777,12 @@ func (d *DataAccessService) GetMachineNotifications(ctx context.Context, userId
// Calculate the result
cursorData := notificationHistory
for _, notification := range notificationHistory {
resultEntry := t.NotificationMachinesTableRow{
result = append(result, t.NotificationMachinesTableRow{
MachineName: notification.MachineName,
Threshold: notification.EventThreshold,
EventType: string(notification.EventType),
Timestamp: notification.Ts.Unix(),
}
switch notification.EventType {
case types.MonitoringMachineOfflineEventName:
resultEntry.EventType = "offline"
case types.MonitoringMachineDiskAlmostFullEventName:
resultEntry.EventType = "storage"
case types.MonitoringMachineCpuLoadEventName:
resultEntry.EventType = "cpu"
case types.MonitoringMachineMemoryUsageEventName:
resultEntry.EventType = "memory"
default:
return nil, nil, fmt.Errorf("invalid event name for machine notification: %v", notification.EventType)
}
result = append(result, resultEntry)
})
}

// -------------------------------------
Expand Down Expand Up @@ -996,19 +984,16 @@ func (d *DataAccessService) GetNetworkNotifications(ctx context.Context, userId
resultEntry := t.NotificationNetworksTableRow{
ChainId: notification.Network,
Timestamp: notification.Ts.Unix(),
EventType: string(notification.EventType),
}
switch notification.EventType {
case types.NetworkGasAboveThresholdEventName:
resultEntry.EventType = "gas_above"
resultEntry.Threshold = decimal.NewFromFloat(notification.EventThreshold).Mul(decimal.NewFromInt(params.GWei))
case types.NetworkGasBelowThresholdEventName:
resultEntry.EventType = "gas_below"
resultEntry.Threshold = decimal.NewFromFloat(notification.EventThreshold).Mul(decimal.NewFromInt(params.GWei))
case types.NetworkParticipationRateThresholdEventName:
resultEntry.EventType = "participation_rate"
resultEntry.Threshold = decimal.NewFromFloat(notification.EventThreshold)
case types.RocketpoolNewClaimRoundStartedEventName:
resultEntry.EventType = "new_reward_round"
default:
return nil, nil, fmt.Errorf("invalid event name for network notification: %v", notification.EventType)
}
Expand Down

0 comments on commit 6233664

Please sign in to comment.