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

This commit is contained in:
2026-04-30 02:39:50 +02:00
parent 9c9ec477d0
commit 0c5c89acfa
11 changed files with 961 additions and 65 deletions

View File

@@ -302,42 +302,10 @@ final class FxRatesService
public function runScheduledRefresh(array $context = []): array
{
if (!$this->dailyRefreshEnabled()) {
return ['ok' => true, 'message' => 'Taeglicher FX-Abruf ist deaktiviert.', 'skipped' => true];
}
$timezone = $this->scheduleTimezone();
$nowLocal = new DateTimeImmutable('now', $timezone);
$targetHour = $this->dailyRefreshHour();
if ((int) $nowLocal->format('G') !== $targetHour) {
return [
'ok' => true,
'message' => 'Kein FX-Abruf: aktuelles Zeitfenster ist ' . $nowLocal->format('H:i') . ', Ziel ist ' . str_pad((string) $targetHour, 2, '0', STR_PAD_LEFT) . ':00.',
'skipped' => true,
'context' => $context,
];
}
$latest = $this->repository->getLatestFetch($this->defaultBaseCurrency());
if (is_array($latest) && trim((string) ($latest['fetched_at'] ?? '')) !== '') {
$latestLocal = new DateTimeImmutable((string) $latest['fetched_at'], new DateTimeZone('UTC'));
$latestLocal = $latestLocal->setTimezone($timezone);
if ($latestLocal->format('Y-m-d') === $nowLocal->format('Y-m-d') && (int) $latestLocal->format('G') >= $targetHour) {
return [
'ok' => true,
'message' => 'Kein FX-Abruf: fuer heute existiert bereits ein Snapshot nach ' . str_pad((string) $targetHour, 2, '0', STR_PAD_LEFT) . ':00.',
'skipped' => true,
'fetch' => $this->localizeFetch($latest),
'context' => $context,
];
}
}
$result = $this->refreshLatestRates(null, $this->defaultBaseCurrency());
return [
'ok' => true,
'message' => 'Taeglicher FX-Abruf ausgefuehrt: ' . (int) ($result['updated_count'] ?? 0) . ' Kurse gespeichert.',
'message' => 'Geplanter FX-Abruf ausgefuehrt: ' . (int) ($result['updated_count'] ?? 0) . ' Kurse gespeichert.',
'result' => $result,
'context' => $context,
];
@@ -980,16 +948,6 @@ final class FxRatesService
return $this->normalizeCurrency((string) ($this->settings['default_base_currency'] ?? 'EUR')) ?: 'EUR';
}
private function dailyRefreshEnabled(): bool
{
return !empty($this->settings['daily_refresh_enabled']);
}
private function dailyRefreshHour(): int
{
return max(0, min(23, (int) ($this->settings['daily_refresh_hour'] ?? 18)));
}
private function scheduleTimezone(): DateTimeZone
{
$timezone = trim((string) ($this->settings['schedule_timezone'] ?? 'Europe/Berlin'));