Skip to content

Commit a564976

Browse files
remoteramienzo-bitfly
authored andcommitted
chore: remove superfluous clickhouse checks
1 parent cf613dd commit a564976

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

backend/pkg/api/data_access/vdb_rewards.go

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ func (d *DataAccessService) GetValidatorDashboardRewards(ctx context.Context, da
8989
With("validators", goqu.L("(SELECT validator_index as validator_index, group_id FROM users_val_dashboards_validators WHERE dashboard_id = ?)", dashboardId.Id)).
9090
Select(
9191
goqu.L("e.epoch"),
92-
goqu.L(`SUM(COALESCE(e.attestations_reward, 0) + COALESCE(e.blocks_cl_reward, 0) + COALESCE(e.sync_reward, 0)) AS cl_rewards`),
93-
goqu.L("SUM(COALESCE(e.attestations_scheduled, 0)) AS attestations_scheduled"),
94-
goqu.L("SUM(COALESCE(e.attestations_observed, 0)) AS attestations_observed"),
95-
goqu.L("SUM(COALESCE(e.blocks_scheduled, 0)) AS blocks_scheduled"),
96-
goqu.L("SUM(COALESCE(e.blocks_proposed, 0)) AS blocks_proposed"),
97-
goqu.L("SUM(COALESCE(e.sync_scheduled, 0)) AS sync_scheduled"),
98-
goqu.L("SUM(COALESCE(e.sync_executed, 0)) AS sync_executed"),
92+
goqu.L(`SUM(e.attestations_reward + e.blocks_cl_reward + e.sync_reward) AS cl_rewards`),
93+
goqu.L("SUM(e.attestations_scheduled) AS attestations_scheduled"),
94+
goqu.L("SUM(e.attestations_observed) AS attestations_observed"),
95+
goqu.L("SUM(e.blocks_scheduled) AS blocks_scheduled"),
96+
goqu.L("SUM(e.blocks_proposed) AS blocks_proposed"),
97+
goqu.L("SUM(e.sync_scheduled) AS sync_scheduled"),
98+
goqu.L("SUM(e.sync_executed) AS sync_executed"),
9999
goqu.L("SUM(CASE WHEN e.slashed THEN 1 ELSE 0 END) AS slashed_in_epoch"),
100-
goqu.L("SUM(COALESCE(e.blocks_slashing_count, 0)) AS slashed_amount")).
100+
goqu.L("SUM(e.blocks_slashing_count) AS slashed_amount")).
101101
Where(goqu.L("e.epoch_timestamp >= fromUnixTimestamp(?)", utils.EpochToTime(startEpoch).Unix()))
102102

103103
elDs := goqu.Dialect("postgres").
@@ -526,26 +526,26 @@ func (d *DataAccessService) GetValidatorDashboardGroupRewards(ctx context.Contex
526526
From(goqu.L("validator_dashboard_data_epoch e")).
527527
With("validators", goqu.L("(SELECT validator_index as validator_index, group_id FROM users_val_dashboards_validators WHERE dashboard_id = ?)", dashboardId.Id)).
528528
Select(
529-
goqu.L("COALESCE(e.attestations_source_reward, 0) AS attestations_source_reward"),
530-
goqu.L("COALESCE(e.attestations_target_reward, 0) AS attestations_target_reward"),
531-
goqu.L("COALESCE(e.attestations_head_reward, 0) AS attestations_head_reward"),
532-
goqu.L("COALESCE(e.attestations_inactivity_reward, 0) AS attestations_inactivity_reward"),
533-
goqu.L("COALESCE(e.attestations_inclusion_reward, 0) AS attestations_inclusion_reward"),
534-
goqu.L("COALESCE(e.attestations_scheduled, 0) AS attestations_scheduled"),
535-
goqu.L("COALESCE(e.attestations_head_executed, 0) AS attestations_head_executed"),
536-
goqu.L("COALESCE(e.attestations_source_executed, 0) AS attestations_source_executed"),
537-
goqu.L("COALESCE(e.attestations_target_executed, 0) AS attestations_target_executed"),
538-
goqu.L("COALESCE(e.blocks_scheduled, 0) AS blocks_scheduled"),
539-
goqu.L("COALESCE(e.blocks_proposed, 0) AS blocks_proposed"),
540-
goqu.L("COALESCE(e.blocks_cl_reward, 0) AS blocks_cl_reward"),
541-
goqu.L("COALESCE(e.sync_scheduled, 0) AS sync_scheduled"),
542-
goqu.L("COALESCE(e.sync_executed, 0) AS sync_executed"),
543-
goqu.L("COALESCE(e.sync_reward, 0) AS sync_reward"),
529+
goqu.L("e.attestations_source_reward"),
530+
goqu.L("e.attestations_target_reward"),
531+
goqu.L("e.attestations_head_reward"),
532+
goqu.L("e.attestations_inactivity_reward"),
533+
goqu.L("e.attestations_inclusion_reward"),
534+
goqu.L("e.attestations_scheduled"),
535+
goqu.L("e.attestations_head_executed"),
536+
goqu.L("e.attestations_source_executed"),
537+
goqu.L("e.attestations_target_executed"),
538+
goqu.L("e.blocks_scheduled"),
539+
goqu.L("e.blocks_proposed"),
540+
goqu.L("e.blocks_cl_reward"),
541+
goqu.L("e.sync_scheduled"),
542+
goqu.L("e.sync_executed"),
543+
goqu.L("e.sync_reward"),
544544
goqu.L("(CASE WHEN e.slashed THEN 1 ELSE 0 END) AS slashed_in_epoch"),
545-
goqu.L("COALESCE(e.blocks_slashing_count, 0) AS slashed_amount"),
546-
goqu.L("COALESCE(e.blocks_cl_slasher_reward, 0) AS slasher_reward"),
547-
goqu.L("COALESCE(e.blocks_cl_attestations_reward, 0) AS blocks_cl_attestations_reward"),
548-
goqu.L("COALESCE(e.blocks_cl_sync_aggregate_reward, 0) AS blocks_cl_sync_aggregate_reward")).
545+
goqu.L("e.blocks_slashing_count AS slashed_amount"),
546+
goqu.L("e.blocks_cl_slasher_reward AS slasher_reward"),
547+
goqu.L("e.blocks_cl_attestations_reward"),
548+
goqu.L("e.blocks_cl_sync_aggregate_reward")).
549549
Where(goqu.L("e.epoch_timestamp = fromUnixTimestamp(?)", utils.EpochToTime(epoch).Unix()))
550550

551551
elDs := goqu.Dialect("postgres").
@@ -726,7 +726,7 @@ func (d *DataAccessService) GetValidatorDashboardRewardsChart(ctx context.Contex
726726
// CL
727727
rewardsDs := goqu.Dialect("postgres").
728728
Select(
729-
goqu.L(`SUM(COALESCE(e.attestations_reward, 0) + COALESCE(e.blocks_cl_reward, 0) + COALESCE(e.sync_reward, 0)) AS cl_rewards`),
729+
goqu.L(`SUM(e.attestations_reward + e.blocks_cl_reward + e.sync_reward) AS cl_rewards`),
730730
timeColumn.As("timestamp"),
731731
).
732732
From(dataTable).
@@ -999,31 +999,31 @@ func (d *DataAccessService) GetValidatorDashboardDuties(ctx context.Context, das
999999
rewardsDs := goqu.Dialect("postgres").
10001000
Select(
10011001
goqu.L("e.validator_index"),
1002-
goqu.L("COALESCE(e.attestations_scheduled, 0) AS attestations_scheduled"),
1003-
goqu.L("COALESCE(e.attestations_source_executed, 0) AS attestations_source_executed"),
1004-
goqu.L("COALESCE(e.attestations_source_reward, 0) AS attestations_source_reward"),
1005-
goqu.L("COALESCE(e.attestations_target_executed, 0) AS attestations_target_executed"),
1006-
goqu.L("COALESCE(e.attestations_target_reward, 0) AS attestations_target_reward"),
1007-
goqu.L("COALESCE(e.attestations_head_executed, 0) AS attestations_head_executed"),
1008-
goqu.L("COALESCE(e.attestations_head_reward, 0) AS attestations_head_reward"),
1009-
goqu.L("COALESCE(e.sync_scheduled, 0) AS sync_scheduled"),
1010-
goqu.L("COALESCE(e.sync_executed, 0) AS sync_executed"),
1011-
goqu.L("COALESCE(e.sync_reward, 0) AS sync_reward"),
1002+
goqu.L("e.attestations_scheduled"),
1003+
goqu.L("e.attestations_source_executed"),
1004+
goqu.L("e.attestations_source_reward"),
1005+
goqu.L("e.attestations_target_executed"),
1006+
goqu.L("e.attestations_target_reward"),
1007+
goqu.L("e.attestations_head_executed"),
1008+
goqu.L("e.attestations_head_reward"),
1009+
goqu.L("e.sync_scheduled"),
1010+
goqu.L("e.sync_executed"),
1011+
goqu.L("e.sync_reward"),
10121012
goqu.L("e.slashed AS slashed_in_epoch"),
1013-
goqu.L("COALESCE(e.blocks_slashing_count, 0) AS slashed_amount"),
1014-
goqu.L("COALESCE(e.blocks_cl_slasher_reward, 0) AS slasher_reward"),
1015-
goqu.L("COALESCE(e.blocks_scheduled, 0) AS blocks_scheduled"),
1016-
goqu.L("COALESCE(e.blocks_proposed, 0) AS blocks_proposed"),
1017-
goqu.L("COALESCE(e.blocks_cl_attestations_reward, 0) AS blocks_cl_attestations_reward"),
1018-
goqu.L("COALESCE(e.blocks_cl_sync_aggregate_reward, 0) AS blocks_cl_sync_aggregate_reward")).
1013+
goqu.L("e.blocks_slashing_count AS slashed_amount"),
1014+
goqu.L("e.blocks_cl_slasher_reward AS slasher_reward"),
1015+
goqu.L("e.blocks_scheduled"),
1016+
goqu.L("e.blocks_proposed"),
1017+
goqu.L("e.blocks_cl_attestations_reward"),
1018+
goqu.L("e.blocks_cl_sync_aggregate_reward")).
10191019
From(goqu.L("validator_dashboard_data_epoch e")).
10201020
Where(goqu.L("e.epoch_timestamp = fromUnixTimestamp(?)", utils.EpochToTime(epoch).Unix())).
10211021
Where(goqu.L(`
1022-
(COALESCE(e.attestations_scheduled, 0) +
1023-
COALESCE(e.sync_scheduled,0) +
1024-
COALESCE(e.blocks_scheduled,0) +
1022+
(e.attestations_scheduled +
1023+
e.sync_scheduled +
1024+
e.blocks_scheduled +
10251025
CASE WHEN e.slashed THEN 1 ELSE 0 END +
1026-
COALESCE(e.blocks_slashing_count, 0)) > 0`))
1026+
e.blocks_slashing_count) > 0`))
10271027

10281028
elDs := goqu.Dialect("postgres").
10291029
Select(

0 commit comments

Comments
 (0)