diff --git a/database/database.go b/database/database.go index 370c8e9..8209e2b 100644 --- a/database/database.go +++ b/database/database.go @@ -166,16 +166,21 @@ func (s *DatabaseService) GetBuilderProfits(since, until time.Time) (res []*Buil return res, err } -func (s *DatabaseService) GetStatsForTimerange(since, until time.Time, relay string) (relays []*TopRelayEntry, builders []*TopBuilderEntry, err error) { +func (s *DatabaseService) GetStatsForTimerange(since, until time.Time, relay string) (relays []*TopRelayEntry, builders []*TopBuilderEntry, builderProfits []*BuilderProfitEntry, err error) { relays, err = s.GetTopRelays(since, until) if err != nil { - return nil, nil, err + return nil, nil, nil, err } builders, err = s.GetTopBuilders(since, until, relay) if err != nil { - return nil, nil, err + return nil, nil, nil, err } - return relays, builders, nil + builderProfits, err = s.GetBuilderProfits(since, until) + if err != nil { + return nil, nil, nil, err + } + + return relays, builders, builderProfits, nil } func (s *DatabaseService) GetDeliveredPayloadsForSlot(slot uint64) (res []*DataAPIPayloadDeliveredEntry, err error) { diff --git a/services/website/html.go b/services/website/html.go index 9e7c333..0322987 100644 --- a/services/website/html.go +++ b/services/website/html.go @@ -51,6 +51,7 @@ type HTMLDataDailyStats struct { TopRelays []*database.TopRelayEntry TopBuildersBySummary []*database.TopBuilderEntry + BuilderProfits []*database.BuilderProfitEntry } var funcMap = template.FuncMap{ diff --git a/services/website/templates/daily-stats.html b/services/website/templates/daily-stats.html index 9d17a39..7d1c5fc 100644 --- a/services/website/templates/daily-stats.html +++ b/services/website/templates/daily-stats.html @@ -82,8 +82,147 @@

MEV-Boost Stats for {{ .Day }}

+ +
+ + + + + + + + + + + + + {{ range .BuilderProfits }} + + + + + + + + + {{ end }} + +
Builder extra_dataBlocksBlocks with profitBlocks with subsidyOverall profit (ETH)Subsidies (ETH)
+ {{ if .ExtraData }}{{ .ExtraData }}{{ else }} {{ end }} + {{ if ne (len .Aliases) 0 }} + + + + + {{ end }} + {{ .NumBlocks | prettyInt }}{{ .NumBlocksProfit | prettyInt }}{{ .NumBlocksSubsidised | prettyInt }}{{ .ProfitTotal }}{{ .SubsidiesTotal }}
+
+ + + + + + + {{ end }} \ No newline at end of file diff --git a/services/website/webserver.go b/services/website/webserver.go index 6f57fd1..0147c37 100644 --- a/services/website/webserver.go +++ b/services/website/webserver.go @@ -411,17 +411,17 @@ func (srv *Webserver) handleBuilderProfitMarkdown(w http.ResponseWriter, req *ht _, _ = w.Write(*srv.markdownBuilderProfit) } -func (srv *Webserver) _getDailyStats(t time.Time) (since, until, minDate time.Time, relays []*database.TopRelayEntry, builders []*database.TopBuilderEntry, err error) { +func (srv *Webserver) _getDailyStats(t time.Time) (since, until, minDate time.Time, relays []*database.TopRelayEntry, builders []*database.TopBuilderEntry, builderProfits []*database.BuilderProfitEntry, err error) { now := time.Now().UTC() minDate = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC).Add(-24 * time.Hour).UTC() if t.UTC().After(minDate.UTC()) { - return now, now, minDate, nil, nil, fmt.Errorf("date is too recent") //nolint:goerr113 + return now, now, minDate, nil, nil, nil, fmt.Errorf("date is too recent") //nolint:goerr113 } since = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.UTC) until = time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, 0, time.UTC) - relays, builders, err = srv.db.GetStatsForTimerange(since, until, "") - return since, until, minDate, relays, builders, err + relays, builders, builderProfits, err = srv.db.GetStatsForTimerange(since, until, "") + return since, until, minDate, relays, builders, builderProfits, err } func (srv *Webserver) handleDailyStats(w http.ResponseWriter, req *http.Request) { @@ -434,11 +434,13 @@ func (srv *Webserver) handleDailyStats(w http.ResponseWriter, req *http.Request) return } - since, until, minDate, relays, builders, err := srv._getDailyStats(t) + srv.log.Infof("Loading daily stats for %s ...", t.Format("2006-01-02")) + since, until, minDate, relays, builders, builderProfits, err := srv._getDailyStats(t) if err != nil { srv.RespondError(w, http.StatusBadRequest, err.Error()) return } + srv.log.Infof("Loading daily stats for %s completed. builderProfits: %d", t.Format("2006-01-02"), len(builderProfits)) dateNext := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.UTC).Add(24 * time.Hour).UTC() dayNext := dateNext.Format("2006-01-02") @@ -455,6 +457,7 @@ func (srv *Webserver) handleDailyStats(w http.ResponseWriter, req *http.Request) TimeUntil: until.Format("2006-01-02 15:04"), TopRelays: prepareRelaysEntries(relays), TopBuildersBySummary: consolidateBuilderEntries(builders), + BuilderProfits: consolidateBuilderProfitEntries(builderProfits), } if srv.opts.Dev { @@ -491,7 +494,7 @@ func (srv *Webserver) handleDailyStatsJSON(w http.ResponseWriter, req *http.Requ return } - _, _, _, relays, builders, err := srv._getDailyStats(t) //nolint:dogsled + _, _, _, relays, builders, _, err := srv._getDailyStats(t) //nolint:dogsled if err != nil { srv.RespondError(w, http.StatusBadRequest, err.Error()) return