From 9b45fc5b2be99683fe833bbde923e6567e6cda82 Mon Sep 17 00:00:00 2001 From: Stefan Pletka <124689083+Eisei24@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:09:57 +0200 Subject: [PATCH] Created new db name field --- backend/pkg/api/data_access/clients.go | 12 ++++++++++++ backend/pkg/api/data_access/dummy.go | 12 ++++++++++++ backend/pkg/api/data_access/notifications.go | 6 +++--- backend/pkg/api/types/data_access.go | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/backend/pkg/api/data_access/clients.go b/backend/pkg/api/data_access/clients.go index 2a409a0d0..c3fa5d79b 100644 --- a/backend/pkg/api/data_access/clients.go +++ b/backend/pkg/api/data_access/clients.go @@ -15,63 +15,75 @@ func (d *DataAccessService) GetAllClients() ([]types.ClientInfo, error) { { Id: 0, Name: "Geth", + DbName: "geth", Category: "execution_layer", }, { Id: 1, Name: "Nethermind", + DbName: "nethermind", Category: "execution_layer", }, { Id: 2, Name: "Besu", + DbName: "besu", Category: "execution_layer", }, { Id: 3, Name: "Erigon", + DbName: "erigon", Category: "execution_layer", }, { Id: 4, Name: "Reth", + DbName: "reth", Category: "execution_layer", }, // consensus_layer { Id: 5, Name: "Teku", + DbName: "teku", Category: "consensus_layer", }, { Id: 6, Name: "Prysm", + DbName: "prysm", Category: "consensus_layer", }, { Id: 7, Name: "Nimbus", + DbName: "nimbus", Category: "consensus_layer", }, { Id: 8, Name: "Lighthouse", + DbName: "lighthouse", Category: "consensus_layer", }, { Id: 9, Name: "Lodestar", + DbName: "lodestar", Category: "consensus_layer", }, // other { Id: 10, Name: "Rocketpool Smart Node", + DbName: "rocketpool", Category: "other", }, { Id: 11, Name: "MEV-Boost", + DbName: "mev-boost", Category: "other", }, }, nil diff --git a/backend/pkg/api/data_access/dummy.go b/backend/pkg/api/data_access/dummy.go index 44baa482e..e84e93da8 100644 --- a/backend/pkg/api/data_access/dummy.go +++ b/backend/pkg/api/data_access/dummy.go @@ -418,63 +418,75 @@ func (d *DummyService) GetAllClients() ([]types.ClientInfo, error) { { Id: 0, Name: "Geth", + DbName: "geth", Category: "execution_layer", }, { Id: 1, Name: "Nethermind", + DbName: "nethermind", Category: "execution_layer", }, { Id: 2, Name: "Besu", + DbName: "besu", Category: "execution_layer", }, { Id: 3, Name: "Erigon", + DbName: "erigon", Category: "execution_layer", }, { Id: 4, Name: "Reth", + DbName: "reth", Category: "execution_layer", }, // consensus_layer { Id: 5, Name: "Teku", + DbName: "teku", Category: "consensus_layer", }, { Id: 6, Name: "Prysm", + DbName: "prysm", Category: "consensus_layer", }, { Id: 7, Name: "Nimbus", + DbName: "nimbus", Category: "consensus_layer", }, { Id: 8, Name: "Lighthouse", + DbName: "lighthouse", Category: "consensus_layer", }, { Id: 9, Name: "Lodestar", + DbName: "lodestar", Category: "consensus_layer", }, // other { Id: 10, Name: "Rocketpool Smart Node", + DbName: "rocketpool", Category: "other", }, { Id: 11, Name: "MEV-Boost", + DbName: "mev-boost", Category: "other", }, }, nil diff --git a/backend/pkg/api/data_access/notifications.go b/backend/pkg/api/data_access/notifications.go index 7b055609d..0651987c4 100644 --- a/backend/pkg/api/data_access/notifications.go +++ b/backend/pkg/api/data_access/notifications.go @@ -992,7 +992,7 @@ func (d *DataAccessService) GetNotificationSettings(ctx context.Context, userId } clientSettings := make(map[string]*t.NotificationSettingsClient, len(clients)) for _, client := range clients { - clientSettings[strings.ToLower(client.Name)] = &t.NotificationSettingsClient{ + clientSettings[client.DbName] = &t.NotificationSettingsClient{ Id: client.Id, Name: client.Name, Category: client.Category, @@ -1447,10 +1447,10 @@ func (d *DataAccessService) UpdateNotificationSettingsClients(ctx context.Contex VALUES ($1, $2, $3, NOW(), $4) ON CONFLICT (user_id, event_name, event_filter) DO NOTHING`, - userId, types.EthClientUpdateEventName, strings.ToLower(clientInfo.Name), utils.TimeToEpoch(time.Now())) + userId, types.EthClientUpdateEventName, clientInfo.DbName, utils.TimeToEpoch(time.Now())) } else { _, err = d.userWriter.ExecContext(ctx, `DELETE FROM users_subscriptions WHERE user_id = $1 AND event_name = $2 AND event_filter = $3`, - userId, types.EthClientUpdateEventName, strings.ToLower(clientInfo.Name)) + userId, types.EthClientUpdateEventName, clientInfo.DbName) } if err != nil { return nil, err diff --git a/backend/pkg/api/types/data_access.go b/backend/pkg/api/types/data_access.go index 4e3c88b17..1cc075183 100644 --- a/backend/pkg/api/types/data_access.go +++ b/backend/pkg/api/types/data_access.go @@ -174,6 +174,7 @@ type NetworkInfo struct { type ClientInfo struct { Id uint64 Name string + DbName string Category string }