Skip to content

Commit

Permalink
website: require on-chain check complete for top-builder query
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Jun 13, 2024
1 parent 3b017ce commit 94aa129
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (s *DatabaseService) GetTopRelays(since, until time.Time) (res []*TopRelayE
endSlot := timeToSlot(until)

// query := `SELECT relay, count(relay) as payloads FROM ` + TableDataAPIPayloadDelivered + ` WHERE inserted_at > $1 AND inserted_at < $2 GROUP BY relay ORDER BY payloads DESC;`
query := `SELECT relay, count(relay) as payloads FROM ` + TableDataAPIPayloadDelivered + ` WHERE slot >= $1 AND slot <= $2 GROUP BY relay ORDER BY payloads DESC;`
query := `SELECT relay, count(relay) as payloads FROM ` + TableDataAPIPayloadDelivered + ` WHERE value_check_ok IS NOT NULL AND slot >= $1 AND slot <= $2 GROUP BY relay ORDER BY payloads DESC;`
err = s.DB.Select(&res, query, startSlot, endSlot)
return res, err
}
Expand All @@ -143,7 +143,7 @@ func (s *DatabaseService) GetTopBuilders(since, until time.Time, relay string) (
endSlot := timeToSlot(until)

query := `SELECT extra_data, count(extra_data) as blocks FROM (
SELECT distinct(slot), extra_data FROM ` + TableDataAPIPayloadDelivered + ` WHERE slot >= $1 AND slot <= $2`
SELECT distinct(slot), extra_data FROM ` + TableDataAPIPayloadDelivered + ` WHERE value_check_ok IS NOT NULL AND slot >= $1 AND slot <= $2`
if relay != "" {
query += ` AND relay = '` + relay + `'`
}
Expand All @@ -167,7 +167,7 @@ func (s *DatabaseService) GetBuilderProfits(since, until time.Time) (res []*Buil
round(sum(CASE WHEN coinbase_diff_eth IS NOT NULL THEN coinbase_diff_eth ELSE 0 END), 4) as total_profit,
round(abs(sum(CASE WHEN coinbase_diff_eth < 0 THEN coinbase_diff_eth ELSE 0 END)), 4) as total_subsidies
FROM (
SELECT distinct(slot), extra_data, coinbase_diff_eth FROM ` + TableDataAPIPayloadDelivered + ` WHERE slot >= $1 AND slot <= $2
SELECT distinct(slot), extra_data, coinbase_diff_eth FROM ` + TableDataAPIPayloadDelivered + ` WHERE value_check_ok IS NOT NULL AND slot >= $1 AND slot <= $2
) AS x
GROUP BY extra_data
ORDER BY total_profit DESC;`
Expand Down

0 comments on commit 94aa129

Please sign in to comment.