44 "context"
55 "database/sql"
66 "fmt"
7+ "maps"
78 "math"
89 "math/big"
910 "slices"
@@ -1030,7 +1031,7 @@ func (d *DataAccessService) GetValidatorDashboardSummaryChart(ctx context.Contex
10301031 }
10311032 }
10321033
1033- totalLineRequested := requestedGroupsMap [t .AllGroups ]
1034+ totalLineRequested := requestedGroupsMap [t .AllGroups ] || dashboardId . AggregateGroups
10341035 averageNetworkLineRequested := requestedGroupsMap [t .NetworkAverage ]
10351036
10361037 if dashboardId .Validators != nil {
@@ -1080,6 +1081,7 @@ func (d *DataAccessService) GetValidatorDashboardSummaryChart(ctx context.Contex
10801081 // convert the returned data to the expected return type (not pretty)
10811082 tsMap := make (map [time.Time ]bool )
10821083 data := make (map [time.Time ]map [int64 ]float64 )
1084+ groupMap := make (map [int64 ]bool )
10831085
10841086 totalEfficiencyMap := make (map [time.Time ]* t.VDBValidatorSummaryChartRow )
10851087 for _ , row := range queryResults {
@@ -1089,13 +1091,14 @@ func (d *DataAccessService) GetValidatorDashboardSummaryChart(ctx context.Contex
10891091 data [row .Timestamp ] = make (map [int64 ]float64 )
10901092 }
10911093
1092- if requestedGroupsMap [row .GroupId ] {
1094+ if ! dashboardId . AggregateGroups && requestedGroupsMap [row .GroupId ] {
10931095 groupEfficiency , err := d .calculateChartEfficiency (efficiency , row )
10941096 if err != nil {
10951097 return nil , err
10961098 }
10971099
10981100 data [row.Timestamp ][row.GroupId ] = groupEfficiency
1101+ groupMap [row .GroupId ] = true
10991102 }
11001103
11011104 if totalLineRequested {
@@ -1125,17 +1128,23 @@ func (d *DataAccessService) GetValidatorDashboardSummaryChart(ctx context.Contex
11251128 for ts := range tsMap {
11261129 data [ts ][int64 (t .NetworkAverage )] = averageNetworkEfficiency
11271130 }
1131+ groupMap [t .NetworkAverage ] = true
11281132 }
11291133
11301134 if totalLineRequested {
1135+ totalLineGroupId := int64 (t .AllGroups )
1136+ if dashboardId .AggregateGroups {
1137+ totalLineGroupId = t .DefaultGroupId
1138+ }
11311139 for _ , row := range totalEfficiencyMap {
11321140 totalEfficiency , err := d .calculateChartEfficiency (efficiency , row )
11331141 if err != nil {
11341142 return nil , err
11351143 }
11361144
1137- data [row.Timestamp ][t. AllGroups ] = totalEfficiency
1145+ data [row.Timestamp ][totalLineGroupId ] = totalEfficiency
11381146 }
1147+ groupMap [totalLineGroupId ] = true
11391148 }
11401149
11411150 tsArray := make ([]time.Time , 0 , len (tsMap ))
@@ -1146,13 +1155,8 @@ func (d *DataAccessService) GetValidatorDashboardSummaryChart(ctx context.Contex
11461155 return tsArray [i ].Before (tsArray [j ])
11471156 })
11481157
1149- groupsArray := make ([]int64 , 0 , len (requestedGroupsMap ))
1150- for group := range requestedGroupsMap {
1151- groupsArray = append (groupsArray , group )
1152- }
1153- sort .Slice (groupsArray , func (i , j int ) bool {
1154- return groupsArray [i ] < groupsArray [j ]
1155- })
1158+ groupsArray := slices .Collect (maps .Keys (groupMap ))
1159+ slices .Sort (groupsArray )
11561160
11571161 ret .Categories = make ([]uint64 , 0 , len (tsArray ))
11581162 for _ , ts := range tsArray {
@@ -1161,7 +1165,7 @@ func (d *DataAccessService) GetValidatorDashboardSummaryChart(ctx context.Contex
11611165 ret .Series = make ([]t.ChartSeries [int , float64 ], 0 , len (groupsArray ))
11621166
11631167 seriesMap := make (map [int64 ]* t.ChartSeries [int , float64 ])
1164- for group := range requestedGroupsMap {
1168+ for _ , group := range groupsArray {
11651169 series := t.ChartSeries [int , float64 ]{
11661170 Id : int (group ),
11671171 Data : make ([]float64 , 0 , len (tsMap )),
0 commit comments