Skip to content

Commit

Permalink
group ids fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
remoterami committed Oct 2, 2024
1 parent 6db47db commit 3e1f57c
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions backend/pkg/api/data_access/vdb_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,8 @@ func (d *DataAccessService) GetValidatorDashboardBlocks(ctx context.Context, das
}

groupIdCol := "group_id"
// this is actually just used for sorting for "reward".. will not consider EL rewards of unfinalized blocks atm
// reward := "reward"
if dashboardId.Validators != nil {
groupIdCol = fmt.Sprintf("%d AS %s", t.DefaultGroupId, groupIdCol)
// reward = "coalesce(rb.value / 1e18, ep.fee_recipient_reward) AS " + reward
}
selectFields := fmt.Sprintf(`
blocks.proposer,
Expand Down Expand Up @@ -306,29 +303,28 @@ func (d *DataAccessService) GetValidatorDashboardBlocks(ctx context.Context, das
params = append(params, scheduledEpochs)
params = append(params, scheduledSlots)
cte += fmt.Sprintf(`,
scheduled_blocks (
proposer,
epoch,
slot,
group_id,
status,
exec_block_number,
fee_recipient,
el_reward,
cl_reward,
graffiti_text
) AS (SELECT
*,
0,
'0',
null::int,
''::bytea,
null::int,
null::int,
''
FROM unnest($%d::int[], $%d::int[], $%d::int[])
)
`, len(params)-2, len(params)-1, len(params))
scheduled_blocks as (
SELECT
prov.proposer,
prov.epoch,
prov.slot,
%s,
'0'::text AS status,
NULL::int AS exec_block_number,
''::bytea AS fee_recipient,
NULL::float AS el_reward,
NULL::float AS cl_reward,
''::text AS graffiti_text
FROM unnest($%d::int[], $%d::int[], $%d::int[]) AS prov(proposer, epoch, slot)
`, groupIdCol, len(params)-2, len(params)-1, len(params))
if dashboardId.Validators == nil {
// add group id
cte += fmt.Sprintf(`INNER JOIN users_val_dashboards_validators validators
ON validators.dashboard_id = $1
AND validators.validator_index = ANY($%d::int[])
`, len(params)-2)
}
cte += `) `
if len(distinct) != 0 {
distinct += ", "
}
Expand Down

0 comments on commit 3e1f57c

Please sign in to comment.