mirror of
https://github.com/Retropex/custom-ocean.xyz-dashboard.git
synced 2025-05-12 19:20:45 +02:00
Add pool fees percentage metric to dashboard
Updated `MiningDashboardService` to calculate and display the `pool_fees_percentage` metric, reflecting earnings lost to pool fees. Enhanced error handling for earnings processing. Updated styles in `dashboard.css` for the new metric and added corresponding HTML elements in `dashboard.html` to ensure proper display and conditional rendering.
This commit is contained in:
parent
d98d496bd6
commit
982fe295d2
@ -128,7 +128,8 @@ class MiningDashboardService:
|
|||||||
'last_block_time': ocean_data.last_block_time,
|
'last_block_time': ocean_data.last_block_time,
|
||||||
'total_last_share': ocean_data.total_last_share,
|
'total_last_share': ocean_data.total_last_share,
|
||||||
'blocks_found': ocean_data.blocks_found or "0",
|
'blocks_found': ocean_data.blocks_found or "0",
|
||||||
'last_block_earnings': ocean_data.last_block_earnings
|
'last_block_earnings': ocean_data.last_block_earnings,
|
||||||
|
'pool_fees_percentage': ocean_data.pool_fees_percentage,
|
||||||
}
|
}
|
||||||
metrics['estimated_earnings_per_day_sats'] = int(round(estimated_earnings_per_day * self.sats_per_btc))
|
metrics['estimated_earnings_per_day_sats'] = int(round(estimated_earnings_per_day * self.sats_per_btc))
|
||||||
metrics['estimated_earnings_next_block_sats'] = int(round(estimated_earnings_next_block * self.sats_per_btc))
|
metrics['estimated_earnings_next_block_sats'] = int(round(estimated_earnings_next_block * self.sats_per_btc))
|
||||||
@ -213,15 +214,28 @@ class MiningDashboardService:
|
|||||||
latest_row = earnings_table.find('tr', class_='table-row')
|
latest_row = earnings_table.find('tr', class_='table-row')
|
||||||
if latest_row:
|
if latest_row:
|
||||||
cells = latest_row.find_all('td', class_='table-cell')
|
cells = latest_row.find_all('td', class_='table-cell')
|
||||||
if len(cells) >= 3:
|
if len(cells) >= 4: # Ensure there are enough cells for earnings and pool fees
|
||||||
earnings_text = cells[2].get_text(strip=True)
|
earnings_text = cells[2].get_text(strip=True)
|
||||||
|
pool_fees_text = cells[3].get_text(strip=True)
|
||||||
|
|
||||||
|
# Parse earnings and pool fees
|
||||||
earnings_value = earnings_text.replace('BTC', '').strip()
|
earnings_value = earnings_text.replace('BTC', '').strip()
|
||||||
|
pool_fees_value = pool_fees_text.replace('BTC', '').strip()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Convert earnings to BTC and sats
|
||||||
btc_earnings = float(earnings_value)
|
btc_earnings = float(earnings_value)
|
||||||
sats = int(round(btc_earnings * 100000000))
|
sats = int(round(btc_earnings * 100_000_000))
|
||||||
data.last_block_earnings = str(sats)
|
data.last_block_earnings = str(sats)
|
||||||
except Exception:
|
|
||||||
|
# Calculate percentage lost to pool fees
|
||||||
|
btc_pool_fees = float(pool_fees_value)
|
||||||
|
percentage_lost = (btc_pool_fees / btc_earnings) * 100 if btc_earnings > 0 else 0
|
||||||
|
data.pool_fees_percentage = round(percentage_lost, 2)
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Error converting earnings or calculating percentage: {e}")
|
||||||
data.last_block_earnings = earnings_value
|
data.last_block_earnings = earnings_value
|
||||||
|
data.pool_fees_percentage = None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error parsing earnings data: {e}")
|
logging.error(f"Error parsing earnings data: {e}")
|
||||||
|
|
||||||
|
@ -151,9 +151,10 @@
|
|||||||
#workers_hashing,
|
#workers_hashing,
|
||||||
#last_share,
|
#last_share,
|
||||||
#blocks_found,
|
#blocks_found,
|
||||||
#last_block_height {
|
#last_block_height,
|
||||||
color: #ffffff;
|
#pool_fees_percentage {
|
||||||
text-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
|
color: #ffffff;
|
||||||
|
text-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Blue metrics (time data) */
|
/* Blue metrics (time data) */
|
||||||
|
@ -39,6 +39,17 @@
|
|||||||
<strong>Last Share:</strong>
|
<strong>Last Share:</strong>
|
||||||
<span id="last_share" class="metric-value">{{ metrics.total_last_share or "N/A" }}</span>
|
<span id="last_share" class="metric-value">{{ metrics.total_last_share or "N/A" }}</span>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>Pool Fees:</strong>
|
||||||
|
<span id="pool_fees_percentage" class="metric-value">
|
||||||
|
{% if metrics and metrics.pool_fees_percentage is defined %}
|
||||||
|
{{ metrics.pool_fees_percentage }}%
|
||||||
|
{% else %}
|
||||||
|
N/A
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
<span id="indicator_pool_fees_percentage"></span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user