Show stats by worker in daily stats

This commit is contained in:
Pijus Kamandulis 2025-07-04 19:04:24 +03:00
parent 11cc168b3a
commit b3c89a01d0
2 changed files with 62 additions and 6 deletions

View File

@ -295,6 +295,9 @@ func GetDailyStats(db *clover.DB, date time.Time) (*models.DailyStats, error) {
}
for workerName, workerShares := range sharesByWorker {
workerHashrate := helpers.CalculateAverageHashrate(workerShares)
sort.Slice(workerShares, func(i, j int) bool {
return workerShares[i].SDiff > workerShares[j].SDiff
})
workerTopShare := workerShares[0] // Already sorted by SDiff
stats.Workers[workerName] = models.WorkerDailyStats{

View File

@ -1,8 +1,25 @@
{{ define "title" }}Daily Stats{{ end }} {{ define "header" }}📊 Pool Daily
Stats{{ end }} {{ define "content" }}
<style>
.worker-rows {
display: none;
}
.expand-btn {
cursor: pointer;
}
.worker-table {
width: 100%;
}
.worker-table th,
.worker-table td {
font-size: 0.9em;
}
</style>
<table>
<thead>
<tr>
<th></th>
<th>Date (UTC)</th>
<th>Share Count</th>
<th>Top Share Diff</th>
@ -10,20 +27,56 @@ Stats{{ end }} {{ define "content" }}
</tr>
</thead>
<tbody>
{{ range .DailyStats }}
{{ range $i, $ds := .DailyStats }}
<tr>
<td>{{ .Date }}</td>
<td>{{ .ShareCount }}</td>
<td>{{ humanDiff .TopShare.SDiff }}</td>
<td>{{ formatHashrate .PoolHashrate }}</td>
<td>
<span class="expand-btn" onclick="toggleWorkers({{ $i }})"></span>
</td>
<td>{{ $ds.Date }}</td>
<td>{{ $ds.ShareCount }}</td>
<td>{{ humanDiff $ds.TopShare.SDiff }}</td>
<td>{{ formatHashrate $ds.PoolHashrate }}</td>
</tr>
{{ else }}
<tr class="worker-rows" id="workers-{{ $i }}">
<td colspan="5">
<table class="worker-table">
<thead>
<tr>
<td colspan="4">No stats found for this date range.</td>
<th>Shares</th>
<th>Top Share Diff</th>
<th>Hashrate</th>
</tr>
</thead>
<tbody>
{{ range $name, $w := $ds.Workers }}
<tr>
<td>{{ $w.Shares }}</td>
<td>{{ humanDiff $w.TopShare.SDiff }}</td>
<td>{{ formatHashrate $w.Hashrate }}</td>
</tr>
{{ end }}
</tbody>
</table>
</td>
</tr>
{{ else }}
<tr>
<td colspan="5">No stats found for this date range.</td>
</tr>
{{ end }}
</tbody>
</table>
<script>
function toggleWorkers(index) {
const row = document.getElementById(`workers-${index}`);
if (row.style.display === "none" || row.style.display === "") {
row.style.display = "table-row";
} else {
row.style.display = "none";
}
}
</script>
<div>
{{ if .PrevPageAvailable }}