From b536712ea7a5db50cfe9cf9b146484a0c66bfd41 Mon Sep 17 00:00:00 2001 From: smueller Date: Tue, 7 Jul 2026 11:11:10 +0200 Subject: [PATCH] Refactor test mode article fetching logic in index.php and wiki.php. Unified article filtering for both test and live modes, enhancing code clarity and reducing redundancy. --- index.php | 5 ++--- wiki.php | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index a9e4f84..fcbc9dc 100644 --- a/index.php +++ b/index.php @@ -634,11 +634,10 @@ function newsletterData(array $config, bool $testMode = false): array [$start, $end, $periodLabel, $periodKey] = newsletterPeriod($config['period_mode']); $allArticles = fetchLatestArticles($config['wiki_url'], (int)$config['article_fetch_limit']); + // Testversand nutzt denselben Zeitraum wie der Liveversand. + $articles = filterArticlesForPeriod($allArticles, $start, $end, (int)$config['article_limit']); if ($testMode) { - $articles = array_slice($allArticles, 0, (int)$config['article_limit']); $periodKey = 'test-' . date('Y-m-d-H-i-s'); - } else { - $articles = filterArticlesForPeriod($allArticles, $start, $end, (int)$config['article_limit']); } return [$articles, $periodLabel, $periodKey]; diff --git a/wiki.php b/wiki.php index 2b6b2a9..a54eecc 100644 --- a/wiki.php +++ b/wiki.php @@ -635,12 +635,10 @@ function newsletterData(array $config, bool $testMode = false): array [$start, $end, $periodLabel, $periodKey] = newsletterPeriod($config['period_mode']); $allArticles = fetchLatestArticles($config['wiki_url'], (int)$config['article_fetch_limit']); + // Testversand nutzt denselben Zeitraum wie der Liveversand. + $articles = filterArticlesForPeriod($allArticles, $start, $end, (int)$config['article_limit']); if ($testMode) { - $articles = array_slice($allArticles, 0, (int)$config['article_limit']); - $periodLabel = 'aktuelle Übersicht'; $periodKey = 'test-' . date('Y-m-d-H-i-s'); - } else { - $articles = filterArticlesForPeriod($allArticles, $start, $end, (int)$config['article_limit']); } return [$articles, $periodLabel, $periodKey];