update
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-20 00:32:18 +02:00
parent 3ed4fba58c
commit 81d1e486e8
3 changed files with 75 additions and 28 deletions

View File

@@ -201,8 +201,11 @@ final class AnalyticsService
return $result;
}
public function buildSummary(array $measurements, array $settings, array $targets): array
public function buildSummary(array $measurements, array $settings, array $targets, array $options = []): array
{
$includeOfferScenarios = !array_key_exists('include_offer_scenarios', $options) || (bool) $options['include_offer_scenarios'];
$includeLongTermProjection = !array_key_exists('include_long_term_projection', $options) || (bool) $options['include_long_term_projection'];
if ($measurements === []) {
return [
'latest_measurement' => null,
@@ -355,28 +358,35 @@ final class AnalyticsService
'break_even_days_overall' => $this->roundOrNull($breakEvenDaysOverall, 4),
'break_even_eta_at' => $breakEvenProjection['eta'] ?? null,
]);
$currentProjection = $this->projectPerformance(
is_array($settings['cost_plans'] ?? null) ? $settings['cost_plans'] : [],
$purchasedMiners,
$latestSummary,
730
);
$latestSummary = array_merge($latestSummary, [
'projection_days' => $currentProjection['days'],
'projection_two_year_revenue' => $this->roundOrNull($currentProjection['revenue'], 8),
'projection_two_year_cost' => $this->roundOrNull($currentProjection['cost'], 8),
'projection_two_year_profit' => $this->roundOrNull($currentProjection['profit'], 8),
]);
$offerSummary = array_map(
fn (array $offer): array => $this->enrichOfferScenario(
$offer,
$latestSummary,
$currentHashrateMh,
if ($includeLongTermProjection) {
$currentProjection = $this->projectPerformance(
is_array($settings['cost_plans'] ?? null) ? $settings['cost_plans'] : [],
$purchasedMiners
),
$offerSummary
);
$purchasedMiners,
$latestSummary,
730
);
$latestSummary = array_merge($latestSummary, [
'projection_days' => $currentProjection['days'],
'projection_two_year_revenue' => $this->roundOrNull($currentProjection['revenue'], 8),
'projection_two_year_cost' => $this->roundOrNull($currentProjection['cost'], 8),
'projection_two_year_profit' => $this->roundOrNull($currentProjection['profit'], 8),
]);
}
if ($includeOfferScenarios) {
$offerSummary = array_map(
fn (array $offer): array => $this->enrichOfferScenario(
$offer,
$latestSummary,
$currentHashrateMh,
is_array($settings['cost_plans'] ?? null) ? $settings['cost_plans'] : [],
$purchasedMiners
),
$offerSummary
);
} else {
$offerSummary = [];
}
return [
'latest_measurement' => $latestSummary,