Skip to content

Commit

Permalink
(NOBIDS) fix rare error cases when some data is not yet present
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelsc committed Feb 27, 2024
1 parent 4c703d9 commit 294c2ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions db/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -2677,6 +2677,9 @@ func GetCurrentDayClIncome(validator_indices []uint64) (map[uint64]int64, error)
dayIncome := make(map[uint64]int64)
lastDay, err := GetLastExportedStatisticDay()
if err != nil {
if err == ErrNoStats {
return dayIncome, nil
}
return dayIncome, err
}

Expand Down
8 changes: 7 additions & 1 deletion handlers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,13 @@ func getSyncCommitteeSlotsStatistics(validators []uint64, epoch uint64) (types.S
lastExportedEpoch = ((lastExportedDay + 1) * epochsPerDay) - 1
}

err = db.ReaderDb.Get(&syncStats, `SELECT SUM(COALESCE(participated_sync_total, 0)) AS participated, SUM(COALESCE(missed_sync_total, 0)) AS missed FROM validator_stats WHERE day = $1 AND validatorindex = ANY($2)`, lastExportedDay, pq.Array(validators))
err = db.ReaderDb.Get(&syncStats, `
SELECT
COALESCE(SUM(COALESCE(participated_sync_total, 0)), 0) AS participated,
COALESCE(SUM(COALESCE(missed_sync_total, 0)),0) AS missed
FROM validator_stats
WHERE day = $1 AND validatorindex = ANY($2)
`, lastExportedDay, pq.Array(validators))
if err != nil {
return types.SyncCommitteesStats{}, err
}
Expand Down

0 comments on commit 294c2ab

Please sign in to comment.