Skip to content

Commit

Permalink
fix data update by making it concurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Jul 24, 2024
1 parent 4412b41 commit 8dc2298
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 275 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ update-bids-website:
go run . service bidcollect --build-website --build-website-upload

dev-website:
go run . service website --dev
DB_DONT_APPLY_SCHEMA=1 go run . service website --dev

dev-bids-website:
go run . service bidcollect --devserver
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Additional URLs:
- https://www.relayscan.io/stats/day/2023-06-20
- https://www.relayscan.io/stats/day/2023-06-20/json

**Bid Archive**

https://bidarchive.relayscan.io

## Notes

- Work in progress
Expand Down
11 changes: 11 additions & 0 deletions scripts/send-pushover-notification.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <message>"
exit 1
fi

curl -s \
--form-string "token=$PUSHOVER_APP_TOKEN" \
--form-string "user=$PUSHOVER_APP_KEY" \
--form-string "message=$1" \
https://api.pushover.net/1/messages.json
19 changes: 10 additions & 9 deletions services/website/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type Stats struct {
Since time.Time
Until time.Time

TimeStr string // i.e. 24h, 12h, 1h or 7d

TopRelays []*database.TopRelayEntry
TopBuilders []*database.TopBuilderEntry
BuilderProfits []*database.BuilderProfitEntry
Expand All @@ -29,17 +31,16 @@ func NewStats() *Stats {
}

type HTMLData struct {
Title string
Title string
TimeSpans []string
TimeSpan string
View string // overview or builder-profit

GeneratedAt time.Time
LastDataTime time.Time
LastDataTimeString string
LastUpdateSlot uint64
TimeSpans []string
Stats *Stats // stats for this view

TimeSpan string
View string
Stats *Stats
LastUpdateSlot uint64
LastUpdateTime time.Time
LastUpdateTimeStr string
}

type HTMLDataDailyStats struct {
Expand Down
1 change: 1 addition & 0 deletions services/website/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<a class="pure-menu-heading" href="/"><img src="/static/favicon/apple-touch-icon.png" height="16" /> relayscan.io</a>

<ul class="pure-menu-list">
<li class="pure-menu-item"><a href="https://bidarchive.relayscan.io/" class="pure-menu-link">Bid Archive</a></li>
<li class="pure-menu-item"><a href="https://github.com/flashbots/relayscan" class="pure-menu-link">About</a></li>
<li class="pure-menu-item"><a href="https://twitter.com/relayscan_io" class="pure-menu-link"><i class="bi bi-twitter"></i></a></li>
</ul>
Expand Down
8 changes: 4 additions & 4 deletions services/website/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ define "content" }}
{{ $lastDataTime := .LastDataTimeString }}
{{ $lastDataTime := .LastUpdateTime }}
{{ $time := .TimeSpan }}
{{ $view := .View }}

Expand All @@ -9,8 +9,8 @@ <h1 style="margin-bottom:10px;">MEV-Boost Analytics</h1>

<p style="color: #6d6d6d; margin-top:0; line-height: 1.4em;">
<small>
Updated {{ .LastDataTimeString }} UTC / Slot {{ .LastUpdateSlot }}<br>
<span id="updated_ago">({{ .LastDataTime | humanTime }})</span>
Updated at slot {{ .LastUpdateSlot }}
<span id="updated_ago">({{ $lastDataTime | humanTime }})</span>
</small>
</p>
<p id="view-type">
Expand Down Expand Up @@ -207,7 +207,7 @@ <h1 style="margin-bottom:10px;">MEV-Boost Analytics</h1>
return sec + " seconds";
}

var referenceTime = new Date("{{ .LastDataTime }}");
var referenceTime = new Date("{{ $lastDataTime }}");
var timeAgo = timeSince(referenceTime);
if (timeAgo != "") {
document.getElementById("updated_ago").innerText = "(" + timeAgo + " ago)";
Expand Down
7 changes: 0 additions & 7 deletions services/website/types.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package website

// type statsResp struct {
// GeneratedAt uint64 `json:"generated_at"`
// DataStartAt uint64 `json:"data_start_at"`
// TopRelays []*database.TopRelayEntry `json:"top_relays"`
// TopBuilders []*database.TopBuilderEntry `json:"top_builders"`
// }

type HTTPErrorResp struct {
Code int `json:"code"`
Message string `json:"message"`
Expand Down
Loading

0 comments on commit 8dc2298

Please sign in to comment.