Skip to content

Commit

Permalink
output fly.io region within template
Browse files Browse the repository at this point in the history
  • Loading branch information
gernotstarke committed Nov 12, 2023
1 parent 0d26fff commit c52347a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
3 changes: 3 additions & 0 deletions internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ type Arc42Statistics struct {
// this data (from both plausible and GitHub)
HowLongDidItTake string

// WhereDoesItRun stores the fly.io region code
WhereDoesItRun string

// Stats4Site contains the statistics per site or subdomain
Stats4Site [len(Arc42sites)]SiteStats

Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func statsHTMLTableHandler(w http.ResponseWriter, r *http.Request) {
// remember how long it took to update statistics
ArcStats.HowLongDidItTake = strconv.FormatInt(time.Since(startOfProcessing).Milliseconds(), 10)

// try go get the fly.io region where this service is running
ArcStats.WhereDoesItRun = os.Getenv("FLY_REGION")

// 3. handle the CORS stuff
sendCORSHeaders(&w, r)

Expand Down
34 changes: 19 additions & 15 deletions web/arc42statistics.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@
<th>PageViews</th>
</tr>

{{ range .Stats4Site}}
<tr>
<td><a href="https://{{.Site }}">{{.Site}}</a></td>
<td style="border-left: 2px solid black;">{{ .Visitors7d}}</td>
<td>{{ .Pageviews7d}}</td>
<td style="border-left: 2px solid black;">{{ .Visitors30d}}</td>
<td>{{ .Pageviews30d}}</td>
<td style="border-left: 2px solid black;">{{ .Visitors12m}}</td>
<td>{{ .Pageviews12m}}</td>
<td style="border-left: 2px solid black;"><a href="{{.Repo}}/issues">
<img alt="GitHub open issues" src="{{.IssueBadgeURL}}"><img alt="GitHub bugs" src="{{.BugBadgeURL}}">
</a></td>
</tr>
{{ end }}
{{ range .Stats4Site}}
<tr>
<td><a href="https://{{.Site }}">{{.Site}}</a></td>
<td style="border-left: 2px solid black;">{{ .Visitors7d}}</td>
<td>{{ .Pageviews7d}}</td>
<td style="border-left: 2px solid black;">{{ .Visitors30d}}</td>
<td>{{ .Pageviews30d}}</td>
<td style="border-left: 2px solid black;">{{ .Visitors12m}}</td>
<td>{{ .Pageviews12m}}</td>
<td style="border-left: 2px solid black;"><a href="{{.Repo}}/issues">
<img alt="GitHub open issues" src="{{.IssueBadgeURL}}"><img alt="GitHub bugs"
src="{{.BugBadgeURL}}">
</a></td>
</tr>
{{ end }}
<tr>
<td style="border-top: 2px solid black;">Totals:</td>
<td style="border-top: 2px solid black;border-left: 2px solid black;">{{ .Totals.SumOfVisitors7d}}</td>
Expand All @@ -48,6 +49,9 @@
Data collected in {{ .HowLongDidItTake }} msecs by arc42 statistics service
(v. {{.AppVersion}}) at {{.LastUpdatedString }} running on
<a href="https://fly.io" target="_blank">
<img src="/images/fly-logo-landscape.svg" width="65px" alt="fly.io">
<img src="/images/fly-logo-landscape.svg" width="60px" alt="fly.io">
</a>
{{if .WhereDoesItRun}}
in region .WhereDoesItRun.
{{end }}
</div>

0 comments on commit c52347a

Please sign in to comment.