Skip to content

Commit

Permalink
relatable
Browse files Browse the repository at this point in the history
  • Loading branch information
snadrus committed Apr 30, 2024
1 parent 461bb5b commit f4763e3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
17 changes: 11 additions & 6 deletions curiosrc/web/hapi/simpleinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"text/template"
"time"

"github.com/dustin/go-humanize"
"github.com/gorilla/mux"
"github.com/samber/lo"
"golang.org/x/xerrors"
Expand Down Expand Up @@ -424,7 +425,10 @@ type machineSummary struct {
ID int64
SinceContact string

RecentTasks []*machineRecentTask
RecentTasks []*machineRecentTask
Cpu int
RamHumanized string
Gpu int
}

type taskSummary struct {
Expand Down Expand Up @@ -487,7 +491,7 @@ func (a *app) clusterMachineSummary(ctx context.Context) ([]machineSummary, erro
}

// Then machine summary
rows, err := a.db.Query(ctx, "SELECT id, host_and_port, last_contact FROM harmony_machines order by host_and_port asc")
rows, err := a.db.Query(ctx, "SELECT id, host_and_port, CURRENT_TIMESTAMP - last_contact, cpu, ram, gpu AS last_contact FROM harmony_machines order by host_and_port asc")
if err != nil {
return nil, err // Handle error
}
Expand All @@ -496,13 +500,14 @@ func (a *app) clusterMachineSummary(ctx context.Context) ([]machineSummary, erro
var summaries []machineSummary
for rows.Next() {
var m machineSummary
var lastContact time.Time
var lastContact time.Duration
var ram int64

if err := rows.Scan(&m.ID, &m.Address, &lastContact); err != nil {
if err := rows.Scan(&m.ID, &m.Address, &lastContact, &m.Cpu, &ram, &m.Gpu); err != nil {
return nil, err // Handle error
}

m.SinceContact = time.Since(lastContact).Round(time.Second).String()
m.SinceContact = lastContact.Round(time.Second).String()
m.RamHumanized = humanize.Bytes(uint64(ram))

// Add recent tasks
if ts, ok := taskSummaries[m.Address]; ok {
Expand Down
3 changes: 3 additions & 0 deletions curiosrc/web/hapi/web/cluster_machines.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<tr>
<td><a href="/hapi/node/{{.ID}}">{{.Address}}</a></td>
<td>{{.ID}}</td>
<td>{{.Cpu}}</td>
<td>{{.RamHumanized}}</td>
<td>{{.Gpu}}</td>
<td>{{.SinceContact}}</td>
{{range .RecentTasks}}
<td>{{.TaskName}}:{{.Success}}{{if ne 0 .Fail}}(<i class="{{if eq 0 .Success}}error{{else}}warning{{end}}">{{.Fail}}</i>){{end}}</td>
Expand Down
17 changes: 10 additions & 7 deletions curiosrc/web/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<curio-ux>
<div class="page">
<div class="row">
<div class="col-md-auto" style="width: 50%">
<div class="col-md-auto" style="max-width: 1000px">
<div class="info-block">
<h2>Chain Connectivity</h2>
<chain-connectivity></chain-connectivity>
Expand All @@ -71,14 +71,17 @@ <h2>Chain Connectivity</h2>
</div>

<div class="row">
<div class="col-md-auto" style="width: 50%">
<div class="col-md-auto" style="max-width: 1000px">
<div class="info-block">
<h2>Cluster Machines</h2>
<table class="table table-dark">
<thead>
<tr>
<th>Host</th>
<th>ID</th>
<th>CPUs</th>
<th>RAM</th>
<th>GPUs</th>
<th>Last Contact</th>
<th>Tasks (24h)</th>
</tr>
Expand All @@ -93,7 +96,7 @@ <h2>Cluster Machines</h2>
</div>

<div class="row">
<div class="col-md-auto" style="width: 50%">
<div class="col-md-auto" style="max-width: 1000px">
<div class="info-block">
<h2><a href="/pipeline_porep.html">PoRep Pipeline</a></h2>
<table class="table table-dark">
Expand All @@ -120,7 +123,7 @@ <h2><a href="/pipeline_porep.html">PoRep Pipeline</a></h2>
</div>

<div class="row">
<div class="col-md-auto" style="width: 50%">
<div class="col-md-auto" style="max-width: 1000px">
<div class="info-block">
<h2>Actor Summary</h2>
<table class="table table-dark">
Expand All @@ -133,7 +136,7 @@ <h2>Actor Summary</h2>
<th>Balance</th>
<th>Available</th>
<th>Worker</th>
<th>Wins</th>
<th style="min-width: 100px">Wins</th>
</tr>
</thead>
<tbody hx-get="/hapi/simpleinfo/actorsummary" hx-trigger="load,every 5s">
Expand All @@ -147,7 +150,7 @@ <h2>Actor Summary</h2>


<div class="row">
<div class="col-md-auto" style="width: 50%">
<div class="col-md-auto" style="max-width: 1000px">
<div class="info-block">
<h2>Recently Finished Tasks</h2>
<table class="table table-dark">
Expand All @@ -174,7 +177,7 @@ <h2>Recently Finished Tasks</h2>
</div>

<div class="row">
<div class="col-md-auto" style="width: 50%">
<div class="col-md-auto" style="max-width: 1000px">
<div class="info-block">
<h2>Cluster Tasks</h2>
<table class="table table-dark">
Expand Down

0 comments on commit f4763e3

Please sign in to comment.