Skip to content

Commit

Permalink
fix: correct group selection in all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
remoterami committed Dec 19, 2024
1 parent 2eda72e commit ddb1da3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions backend/pkg/api/data_access/vdb_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"fmt"
"maps"
"math/big"
"slices"
"sort"
Expand Down Expand Up @@ -909,6 +910,7 @@ func (d *DataAccessService) GetValidatorDashboardRewardsChart(ctx context.Contex
// Create a map structure to store the data
epochStartData := make(map[uint64]map[int]t.ClElValue[decimal.Decimal])
epochStartList := make([]uint64, 0)
groupMap := make(map[int]bool)

for _, res := range queryResult {
if _, ok := epochStartData[res.EpochStart]; !ok {
Expand All @@ -920,17 +922,11 @@ func (d *DataAccessService) GetValidatorDashboardRewardsChart(ctx context.Contex
El: elRewards[res.EpochStart][res.GroupId],
Cl: utils.GWeiToWei(big.NewInt(res.ClRewards)),
}
groupMap[int(res.GroupId)] = true
}

// Get the list of groups
// It should be identical for all epochs (in most cases)
var groupList []int
for _, groupData := range epochStartData {
for groupId := range groupData {
groupList = append(groupList, groupId)
}
break
}
groupList := slices.Collect(maps.Keys(groupMap))
slices.Sort(groupList)

// Create the series structure
Expand Down

0 comments on commit ddb1da3

Please sign in to comment.