update
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user