yXyX
This commit is contained in:
@@ -318,7 +318,7 @@ final class Router
|
||||
'snapshot_limit' => self::BOOTSTRAP_SNAPSHOT_LIMIT,
|
||||
]);
|
||||
|
||||
$settings = $this->safeTimed('bootstrap.settings', fn () => $this->settings($projectKey), [
|
||||
$settings = $this->safeTimed('bootstrap.settings', fn () => $this->settings($projectKey, $this->bootstrapSettingsOptions($view)), [
|
||||
'project_key' => $projectKey,
|
||||
'baseline_measured_at' => null,
|
||||
'baseline_coins_total' => null,
|
||||
@@ -358,7 +358,7 @@ final class Router
|
||||
'view' => $view,
|
||||
'measurement_count' => is_array($measurements) ? count($measurements) : 0,
|
||||
]);
|
||||
$summary = $this->safeTimed('bootstrap.summary', fn () => $this->bootstrapSummary($measurements, $settings, $targets, $view), [
|
||||
$summary = $this->safeTimed('bootstrap.summary', fn () => $this->bootstrapSummary($measurements, $settings, $targets, $walletSnapshots, $view), [
|
||||
'latest_measurement' => $measurements !== [] ? $measurements[array_key_last($measurements)] : null,
|
||||
'baseline' => $settings,
|
||||
'targets' => [],
|
||||
@@ -1147,8 +1147,14 @@ final class Router
|
||||
return abs($leftTs - $rightTs);
|
||||
}
|
||||
|
||||
private function settings(string $projectKey): array
|
||||
private function settings(string $projectKey, array $options = []): array
|
||||
{
|
||||
$includeCostPlans = !array_key_exists('cost_plans', $options) || (bool) $options['cost_plans'];
|
||||
$includeCurrencies = !array_key_exists('currencies', $options) || (bool) $options['currencies'];
|
||||
$includePayouts = !array_key_exists('payouts', $options) || (bool) $options['payouts'];
|
||||
$includeMinerOffers = !array_key_exists('miner_offers', $options) || (bool) $options['miner_offers'];
|
||||
$includePurchasedMiners = !array_key_exists('purchased_miners', $options) || (bool) $options['purchased_miners'];
|
||||
|
||||
$settings = $this->repository()->getSettings($projectKey);
|
||||
$base = is_array($settings) ? $settings : [
|
||||
'project_key' => $projectKey,
|
||||
@@ -1173,12 +1179,12 @@ final class Router
|
||||
$base['module_theme_accent'] = 'teal';
|
||||
}
|
||||
|
||||
$base['cost_plans'] = $this->costPlans($projectKey);
|
||||
$base['currencies'] = $this->currencies();
|
||||
$base['cost_plans'] = $includeCostPlans ? $this->costPlans($projectKey) : [];
|
||||
$base['currencies'] = $includeCurrencies ? $this->currencies() : [];
|
||||
$base['preferred_currencies'] = $this->preferredCurrencies($base['preferred_currencies'] ?? null);
|
||||
$base['payouts'] = $this->payouts($projectKey);
|
||||
$base['miner_offers'] = $this->minerOffers($projectKey);
|
||||
$base['purchased_miners'] = $this->purchasedMiners($projectKey);
|
||||
$base['payouts'] = $includePayouts ? $this->payouts($projectKey) : [];
|
||||
$base['miner_offers'] = $includeMinerOffers ? $this->minerOffers($projectKey) : [];
|
||||
$base['purchased_miners'] = $includePurchasedMiners ? $this->purchasedMiners($projectKey) : [];
|
||||
$base['measurement_rates'] = [];
|
||||
return $base;
|
||||
}
|
||||
@@ -1242,16 +1248,22 @@ final class Router
|
||||
'row_count' => count($rows),
|
||||
'limit' => self::BOOTSTRAP_MEASUREMENT_LIMIT,
|
||||
]);
|
||||
return $this->analytics()->enrichMeasurements($rows, $settings);
|
||||
return $this->analytics()->enrichMeasurements($rows, $settings, [
|
||||
'full_latest_only' => in_array($view, ['overview', 'mining'], true),
|
||||
]);
|
||||
}
|
||||
|
||||
private function bootstrapWalletSnapshots(string $projectKey, string $view): array
|
||||
{
|
||||
if (!in_array($view, ['wallet'], true)) {
|
||||
if ($view === 'wallet') {
|
||||
return $this->repository()->listWalletSnapshots($projectKey, 50);
|
||||
}
|
||||
|
||||
if (!in_array($view, ['overview', 'mining'], true)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->repository()->listWalletSnapshots($projectKey, 50);
|
||||
return $this->repository()->listWalletSnapshots($projectKey, 1);
|
||||
}
|
||||
|
||||
private function bootstrapTargets(string $projectKey, string $view): array
|
||||
@@ -1279,7 +1291,7 @@ final class Router
|
||||
return $this->measurementFxSnapshots($measurements, $limit);
|
||||
}
|
||||
|
||||
private function bootstrapSummary(array $measurements, array $settings, array $targets, string $view): array
|
||||
private function bootstrapSummary(array $measurements, array $settings, array $targets, array $walletSnapshots, string $view): array
|
||||
{
|
||||
if (!in_array($view, ['overview', 'mining'], true)) {
|
||||
return [
|
||||
@@ -1294,6 +1306,7 @@ final class Router
|
||||
return $this->analytics()->buildSummary($measurements, $settings, $targets, [
|
||||
'include_offer_scenarios' => $view === 'mining',
|
||||
'include_long_term_projection' => $view === 'mining',
|
||||
'wallet_snapshots' => $walletSnapshots,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1327,6 +1340,54 @@ final class Router
|
||||
: 'overview';
|
||||
}
|
||||
|
||||
private function bootstrapSettingsOptions(string $view): array
|
||||
{
|
||||
return match ($view) {
|
||||
'overview' => [
|
||||
'cost_plans' => true,
|
||||
'currencies' => true,
|
||||
'payouts' => true,
|
||||
'miner_offers' => false,
|
||||
'purchased_miners' => true,
|
||||
],
|
||||
'upload' => [
|
||||
'cost_plans' => false,
|
||||
'currencies' => true,
|
||||
'payouts' => false,
|
||||
'miner_offers' => false,
|
||||
'purchased_miners' => false,
|
||||
],
|
||||
'measurements' => [
|
||||
'cost_plans' => false,
|
||||
'currencies' => false,
|
||||
'payouts' => false,
|
||||
'miner_offers' => false,
|
||||
'purchased_miners' => false,
|
||||
],
|
||||
'wallet' => [
|
||||
'cost_plans' => false,
|
||||
'currencies' => false,
|
||||
'payouts' => false,
|
||||
'miner_offers' => false,
|
||||
'purchased_miners' => false,
|
||||
],
|
||||
'dashboards' => [
|
||||
'cost_plans' => false,
|
||||
'currencies' => false,
|
||||
'payouts' => false,
|
||||
'miner_offers' => false,
|
||||
'purchased_miners' => false,
|
||||
],
|
||||
default => [
|
||||
'cost_plans' => true,
|
||||
'currencies' => true,
|
||||
'payouts' => true,
|
||||
'miner_offers' => true,
|
||||
'purchased_miners' => true,
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
private function createMeasurement(string $projectKey, array $input): array
|
||||
{
|
||||
$projectTimezone = $this->projectTimezone($projectKey);
|
||||
|
||||
Reference in New Issue
Block a user