Skip to content

Commit c8c0a79

Browse files
committed
chore: remove superfluous clickhouse checks
1 parent 0e64883 commit c8c0a79

File tree

2 files changed

+49
-49
lines changed

2 files changed

+49
-49
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).
@@ -998,31 +998,31 @@ func (d *DataAccessService) GetValidatorDashboardDuties(ctx context.Context, das
998998
rewardsDs := goqu.Dialect("postgres").
999999
Select(
10001000
goqu.L("e.validator_index"),
1001-
goqu.L("COALESCE(e.attestations_scheduled, 0) AS attestations_scheduled"),
1002-
goqu.L("COALESCE(e.attestations_source_executed, 0) AS attestations_source_executed"),
1003-
goqu.L("COALESCE(e.attestations_source_reward, 0) AS attestations_source_reward"),
1004-
goqu.L("COALESCE(e.attestations_target_executed, 0) AS attestations_target_executed"),
1005-
goqu.L("COALESCE(e.attestations_target_reward, 0) AS attestations_target_reward"),
1006-
goqu.L("COALESCE(e.attestations_head_executed, 0) AS attestations_head_executed"),
1007-
goqu.L("COALESCE(e.attestations_head_reward, 0) AS attestations_head_reward"),
1008-
goqu.L("COALESCE(e.sync_scheduled, 0) AS sync_scheduled"),
1009-
goqu.L("COALESCE(e.sync_executed, 0) AS sync_executed"),
1010-
goqu.L("COALESCE(e.sync_reward, 0) AS sync_reward"),
1001+
goqu.L("e.attestations_scheduled"),
1002+
goqu.L("e.attestations_source_executed"),
1003+
goqu.L("e.attestations_source_reward"),
1004+
goqu.L("e.attestations_target_executed"),
1005+
goqu.L("e.attestations_target_reward"),
1006+
goqu.L("e.attestations_head_executed"),
1007+
goqu.L("e.attestations_head_reward"),
1008+
goqu.L("e.sync_scheduled"),
1009+
goqu.L("e.sync_executed"),
1010+
goqu.L("e.sync_reward"),
10111011
goqu.L("e.slashed AS slashed_in_epoch"),
1012-
goqu.L("COALESCE(e.blocks_slashing_count, 0) AS slashed_amount"),
1013-
goqu.L("COALESCE(e.blocks_cl_slasher_reward, 0) AS slasher_reward"),
1014-
goqu.L("COALESCE(e.blocks_scheduled, 0) AS blocks_scheduled"),
1015-
goqu.L("COALESCE(e.blocks_proposed, 0) AS blocks_proposed"),
1016-
goqu.L("COALESCE(e.blocks_cl_attestations_reward, 0) AS blocks_cl_attestations_reward"),
1017-
goqu.L("COALESCE(e.blocks_cl_sync_aggregate_reward, 0) AS blocks_cl_sync_aggregate_reward")).
1012+
goqu.L("e.blocks_slashing_count AS slashed_amount"),
1013+
goqu.L("e.blocks_cl_slasher_reward AS slasher_reward"),
1014+
goqu.L("e.blocks_scheduled"),
1015+
goqu.L("e.blocks_proposed"),
1016+
goqu.L("e.blocks_cl_attestations_reward"),
1017+
goqu.L("e.blocks_cl_sync_aggregate_reward")).
10181018
From(goqu.L("validator_dashboard_data_epoch e")).
10191019
Where(goqu.L("e.epoch_timestamp = fromUnixTimestamp(?)", utils.EpochToTime(epoch).Unix())).
10201020
Where(goqu.L(`
1021-
(COALESCE(e.attestations_scheduled, 0) +
1022-
COALESCE(e.sync_scheduled,0) +
1023-
COALESCE(e.blocks_scheduled,0) +
1021+
(e.attestations_scheduled +
1022+
e.sync_scheduled +
1023+
e.blocks_scheduled +
10241024
CASE WHEN e.slashed THEN 1 ELSE 0 END +
1025-
COALESCE(e.blocks_slashing_count, 0)) > 0`))
1025+
e.blocks_slashing_count) > 0`))
10261026

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

backend/pkg/api/data_access/vdb_summary.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ func (d *DataAccessService) GetValidatorDashboardSlashingsSummaryValidators(ctx
12471247
goqu.L("r.epoch_end"),
12481248
goqu.L("r.validator_index"),
12491249
goqu.L("r.slashed"),
1250-
goqu.L("COALESCE(r.blocks_slashing_count, 0) AS slashed_amount")).
1250+
goqu.L("r.blocks_slashing_count AS slashed_amount")).
12511251
Where(goqu.L("(r.slashed OR r.blocks_slashing_count > 0)"))
12521252

12531253
// handle the case when we have a list of validators

0 commit comments

Comments
 (0)