change stage
All checks were successful
Deploy / deploy-production (push) Has been skipped
Deploy / deploy-staging (push) Successful in 11s

This commit is contained in:
2026-06-07 03:14:09 +02:00
parent a408765e76
commit 7020ae0b1c
3 changed files with 74 additions and 2 deletions

View File

@@ -47,6 +47,7 @@ final class AnalyticsService
$result = [];
$payoutIndex = 0;
$payoutsByAsset = [];
$latestPayoutByAsset = [];
$latestPriceByCurrency = [];
$lastIndex = count($measurements) - 1;
@@ -61,7 +62,13 @@ final class AnalyticsService
}
$payoutAsset = strtoupper(trim((string) ($payouts[$payoutIndex]['payout_currency'] ?? $coinCurrency)));
$payoutsByAsset[$payoutAsset] = ($payoutsByAsset[$payoutAsset] ?? 0.0) + (float) ($payouts[$payoutIndex]['coins_amount'] ?? 0);
$payoutAmount = (float) ($payouts[$payoutIndex]['coins_amount'] ?? 0);
$payoutsByAsset[$payoutAsset] = ($payoutsByAsset[$payoutAsset] ?? 0.0) + $payoutAmount;
$latestPayoutByAsset[$payoutAsset] = [
'payout_at' => (string) ($payouts[$payoutIndex]['payout_at'] ?? ''),
'payout_ts' => $payoutTs,
'coins_amount' => $payoutAmount,
];
$payoutIndex++;
}
@@ -80,6 +87,11 @@ final class AnalyticsService
$perDayInterval = null;
$perHourPerMhInterval = null;
$perDayPerMhInterval = null;
$hoursSinceLastPayout = null;
$coinsSinceLastPayout = null;
$perHourSinceLastPayout = null;
$perDaySinceLastPayout = null;
$lastPayoutAt = null;
if (is_array($previous) && $previousMeasuredTs !== null) {
$intervalStartTs = $previousMeasuredTs;
@@ -98,6 +110,18 @@ final class AnalyticsService
}
}
if (isset($latestPayoutByAsset[$coinCurrency]) && is_array($latestPayoutByAsset[$coinCurrency])) {
$lastPayout = $latestPayoutByAsset[$coinCurrency];
$lastPayoutTs = (int) ($lastPayout['payout_ts'] ?? 0);
if ($lastPayoutTs > 0 && $measuredTs > $lastPayoutTs) {
$hoursSinceLastPayout = ($measuredTs - $lastPayoutTs) / 3600;
$coinsSinceLastPayout = $visibleCoinsTotal;
$perHourSinceLastPayout = $hoursSinceLastPayout > 0 ? $coinsSinceLastPayout / $hoursSinceLastPayout : null;
$perDaySinceLastPayout = $perHourSinceLastPayout !== null ? $perHourSinceLastPayout * 24 : null;
$lastPayoutAt = (string) ($lastPayout['payout_at'] ?? '');
}
}
$trendLabel = 'stabil';
if ($perHourInterval !== null && $previousIntervalRate !== null) {
$delta = $perHourInterval - $previousIntervalRate;
@@ -188,6 +212,11 @@ final class AnalyticsService
'doge_per_day_interval' => $this->roundOrNull($perDayInterval, 6),
'doge_per_hour_per_mh_interval' => $this->roundOrNull($perHourPerMhInterval, 8),
'doge_per_day_per_mh_interval' => $this->roundOrNull($perDayPerMhInterval, 8),
'last_payout_at' => $lastPayoutAt,
'hours_since_last_payout' => $this->roundOrNull($hoursSinceLastPayout, 4),
'coins_since_last_payout' => $this->roundOrNull($coinsSinceLastPayout, 6),
'doge_per_hour_since_last_payout' => $this->roundOrNull($perHourSinceLastPayout, 6),
'doge_per_day_since_last_payout' => $this->roundOrNull($perDaySinceLastPayout, 6),
'trend_label' => $trendLabel,
'effective_price_per_coin' => $this->roundOrNull($price, 8),
'effective_price_currency' => $priceCurrency,