Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/tasks/backlog/P10-T100.md → docs/tasks/done/P10-T100.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# P10-T100: Implement "Worker Detail" page (SSR fragment)

**Phase:** P10 - Dashboard & Monitoring UI
**Status:** Not Started
**Status:** Completed
**Priority:** Medium
**Dependencies:** [P10-T070]
**Estimated Effort:** Medium
Expand All @@ -14,12 +14,12 @@ Create a detailed profile page for each worker. This page aggregates real-time s

## Acceptance Criteria

- [ ] Create route `/dashboard/workers/{worker_id}`.
- [ ] Render worker meta-data (ID, Version, OS/HW Type).
- [ ] Display a worker-specific throughput real-time chart.
- [ ] Display historical volume bar chart (7 days).
- [ ] Add a "Recent Log" or "Latest Checkpoints" list for that specific worker.
- [ ] Allow clicking a worker in the table (P10-T050) to open this view.
- [x] Create route `/dashboard/workers/{worker_id}`.
- [x] Render worker meta-data (ID, Version, OS/HW Type).
- [x] Display a worker-specific throughput real-time chart.
- [x] Display historical volume bar chart (7 days).
- [x] Add a "Recent Log" or "Latest Checkpoints" list for that specific worker.
- [x] Allow clicking a worker in the table (P10-T050) to open this view.

## Implementation Notes

Expand Down
4 changes: 2 additions & 2 deletions go/internal/database/acceptance_optimization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func TestAutomaticAggregationFromHistory(t *testing.T) {
if err != nil {
t.Fatalf("GetWorkerLifetimeStats error: %v", err)
}
if !lifetime.TotalBatches.Valid || lifetime.TotalBatches.Int64 < 100 {
t.Fatalf("expected lifetime.total_batches >= 100, got %+v", lifetime.TotalBatches)
if lifetime.TotalBatches < 100 {
t.Fatalf("expected lifetime.total_batches >= 100, got %d", lifetime.TotalBatches)
}
}

Expand Down
171 changes: 147 additions & 24 deletions go/internal/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 53 additions & 8 deletions go/internal/database/sql/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ SELECT * FROM results
WHERE address = ?
ORDER BY found_at DESC;

-- name: GetResultsByWorker :many
-- Find results by worker ID
SELECT * FROM results
WHERE worker_id = ?
ORDER BY found_at DESC;

-- name: GetAllResults :many
-- Get all results (limited)
SELECT * FROM results
Expand Down Expand Up @@ -183,10 +189,14 @@ SELECT
j.current_nonce,
j.nonce_start,
j.nonce_end,
(SELECT h.keys_per_second
FROM worker_history h
WHERE h.worker_id = w.id
ORDER BY h.finished_at DESC LIMIT 1) as last_kps
COALESCE(
(SELECT CAST(j2.keys_scanned AS REAL) / (CAST(j2.duration_ms AS REAL) / 1000.0)
FROM jobs j2 WHERE j2.id = j.id AND j2.duration_ms > 0),
(SELECT h.keys_per_second
FROM worker_history h
WHERE h.worker_id = w.id
ORDER BY h.finished_at DESC LIMIT 1)
) as last_kps
FROM workers w
LEFT JOIN jobs j ON j.worker_id = w.id AND j.status = 'processing'
WHERE w.last_seen > datetime('now', '-5 minutes')
Expand All @@ -198,6 +208,13 @@ SELECT * FROM workers
WHERE worker_type = ?
ORDER BY last_seen DESC;

-- name: GetWorkerHistoryLogs :many
-- Get latest history logs for a specific worker
SELECT * FROM worker_history
WHERE worker_id = ?
ORDER BY finished_at DESC
LIMIT ?;

-- name: GetStats :one
-- Get aggregated statistics
SELECT * FROM stats_summary;
Expand Down Expand Up @@ -236,7 +253,8 @@ SELECT
keys_scanned, expires_at, created_at, last_checkpoint_at
FROM jobs
WHERE prefix_28 = ?
ORDER BY nonce_start ASC;
ORDER BY created_at DESC
LIMIT 20;

-- name: RecordWorkerStats :exec
-- Insert a raw worker history record (tier 1)
Expand Down Expand Up @@ -426,9 +444,36 @@ ORDER BY total_keys DESC
LIMIT 1;

-- name: GetWorkerLifetimeStats :one
-- Get lifetime stats for a worker
SELECT * FROM worker_stats_lifetime
WHERE worker_id = ? LIMIT 1;
-- Get unified lifetime stats for a single worker
SELECT
CAST(SUM(total_batches) AS INTEGER) as total_batches,
CAST(SUM(total_keys_scanned) AS INTEGER) as total_keys_scanned,
CAST(SUM(total_duration_ms) AS INTEGER) as total_duration_ms,
COALESCE(AVG(keys_per_second_avg), 0.0) as keys_per_second_avg,
COALESCE(MAX(keys_per_second_best), 0.0) as keys_per_second_best
FROM (
-- Archived data (Tier 4)
SELECT
total_batches,
total_keys_scanned,
total_duration_ms,
keys_per_second_avg,
keys_per_second_best
FROM worker_stats_lifetime
WHERE worker_stats_lifetime.worker_id = :worker_id

UNION ALL

-- Recent data (Tier 1)
SELECT
1 as total_batches,
keys_scanned as total_keys_scanned,
duration_ms as total_duration_ms,
keys_per_second as keys_per_second_avg,
keys_per_second as keys_per_second_best
FROM worker_history
WHERE worker_history.worker_id = :worker_id
) AS unified;

-- name: GetAllWorkerLifetimeStats :many
-- Get unified lifetime stats for all workers, combining archived tier 4 and recent tier 1
Expand Down
4 changes: 2 additions & 2 deletions go/internal/database/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ func TestRecordWorkerHistoryAndAggregation(t *testing.T) {
if err != nil {
t.Fatalf("GetWorkerLifetimeStats error: %v", err)
}
if !lifetime.TotalBatches.Valid || lifetime.TotalBatches.Int64 < 1 {
t.Fatalf("expected lifetime.total_batches >= 1, got %+v", lifetime.TotalBatches)
if lifetime.TotalBatches < 1 {
t.Fatalf("expected lifetime.total_batches >= 1, got %d", lifetime.TotalBatches)
}

_ = db // silence unused in some contexts
Expand Down
Loading