- Add SQLite database package for hashrate history persistence with configurable retention - Enhance dashboard with responsive stats bar, improved chart component, and worker selector - Add terminal modal component for console output viewing - Implement comprehensive E2E test suite with page objects pattern - Add history API endpoints for historical data queries - Update worker message handling with proper registration - Add new UI pages structure with layouts and components - Update Docker configuration for Go 1.24 - Add PostCSS configuration for Tailwind CSS processing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
161 lines
4 KiB
Markdown
161 lines
4 KiB
Markdown
# Historical Data
|
|
|
|
The Mining Dashboard stores hashrate history in an SQLite database for charting and analysis.
|
|
|
|
## Database Location
|
|
|
|
```
|
|
~/.local/share/lethean-desktop/mining.db
|
|
```
|
|
|
|
## Data Retention
|
|
|
|
| Time Range | Resolution | Retention |
|
|
|------------|------------|-----------|
|
|
| 0-5 minutes | 10 seconds | In-memory only |
|
|
| 5 min - 24 hours | 1 minute | SQLite |
|
|
| 24 hours+ | 1 minute | Configurable (default 30 days) |
|
|
|
|
## Configuring Retention
|
|
|
|
In `~/.config/lethean-desktop/miners.json`:
|
|
|
|
```json
|
|
{
|
|
"database": {
|
|
"enabled": true,
|
|
"retentionDays": 30
|
|
}
|
|
}
|
|
```
|
|
|
|
### Disable Database
|
|
|
|
```json
|
|
{
|
|
"database": {
|
|
"enabled": false
|
|
}
|
|
}
|
|
```
|
|
|
|
When disabled, only in-memory data is available (last 5 minutes).
|
|
|
|
## Time Range Selection
|
|
|
|
The dashboard supports viewing different time windows:
|
|
|
|
| Label | Minutes | Use Case |
|
|
|-------|---------|----------|
|
|
| 5m | 5 | Real-time monitoring |
|
|
| 15m | 15 | Short-term trends |
|
|
| 30m | 30 | Recent performance |
|
|
| 45m | 45 | Extended recent |
|
|
| 1h | 60 | Last hour |
|
|
| 3h | 180 | Morning/afternoon |
|
|
| 6h | 360 | Half day |
|
|
| 12h | 720 | Full shift |
|
|
| 24h | 1440 | Full day |
|
|
|
|
## Data Schema
|
|
|
|
```sql
|
|
CREATE TABLE hashrate_history (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
miner_name TEXT NOT NULL,
|
|
timestamp DATETIME NOT NULL,
|
|
hashrate INTEGER NOT NULL
|
|
);
|
|
|
|
CREATE INDEX idx_miner_time ON hashrate_history(miner_name, timestamp);
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
### Get Historical Hashrate
|
|
|
|
```bash
|
|
curl "http://localhost:9090/api/v1/mining/history/miners/xmrig-123/hashrate?since=2024-01-15T00:00:00Z&until=2024-01-15T23:59:59Z"
|
|
```
|
|
|
|
Response:
|
|
```json
|
|
[
|
|
{"timestamp": "2024-01-15T10:30:00Z", "hashrate": 1234},
|
|
{"timestamp": "2024-01-15T10:31:00Z", "hashrate": 1256},
|
|
{"timestamp": "2024-01-15T10:32:00Z", "hashrate": 1248}
|
|
]
|
|
```
|
|
|
|
### Get All Miners History
|
|
|
|
```bash
|
|
curl "http://localhost:9090/api/v1/mining/history/miners?since=2024-01-15T00:00:00Z"
|
|
```
|
|
|
|
### Get Miner Stats Summary
|
|
|
|
```bash
|
|
curl "http://localhost:9090/api/v1/mining/history/miners/xmrig-123?since=2024-01-15T00:00:00Z"
|
|
```
|
|
|
|
Response includes:
|
|
- Average hashrate
|
|
- Peak hashrate
|
|
- Total shares
|
|
- Time period
|
|
|
|
## Data Flow
|
|
|
|
```
|
|
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
│ Miner │────▶│ Manager │────▶│ SQLite │
|
|
│ (XMRig) │ │ (polling) │ │ DB │
|
|
└─────────────┘ └─────────────┘ └─────────────┘
|
|
│ │ │
|
|
│ Stats every │ Store every │
|
|
│ 10 seconds │ 1 minute │
|
|
▼ ▼ ▼
|
|
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
│ In-Memory │◀────│ Service │◀────│ Frontend │
|
|
│ Buffer │ │ (API) │ │ (Charts) │
|
|
└─────────────┘ └─────────────┘ └─────────────┘
|
|
```
|
|
|
|
## Automatic Cleanup
|
|
|
|
The database automatically purges old data:
|
|
|
|
1. Runs on startup
|
|
2. Runs every 24 hours
|
|
3. Deletes records older than `retentionDays`
|
|
|
|
## Manual Database Access
|
|
|
|
```bash
|
|
sqlite3 ~/.local/share/lethean-desktop/mining.db
|
|
|
|
# View recent records
|
|
SELECT * FROM hashrate_history
|
|
ORDER BY timestamp DESC
|
|
LIMIT 10;
|
|
|
|
# Get average hashrate for a miner
|
|
SELECT AVG(hashrate) FROM hashrate_history
|
|
WHERE miner_name = 'xmrig-123'
|
|
AND timestamp > datetime('now', '-1 hour');
|
|
|
|
# Database size
|
|
SELECT page_count * page_size as size
|
|
FROM pragma_page_count(), pragma_page_size();
|
|
```
|
|
|
|
## Exporting Data
|
|
|
|
```bash
|
|
sqlite3 ~/.local/share/lethean-desktop/mining.db \
|
|
".mode csv" \
|
|
".headers on" \
|
|
"SELECT * FROM hashrate_history WHERE timestamp > datetime('now', '-24 hours');" \
|
|
> hashrate_export.csv
|
|
```
|