refactor : trending — seul /trending génère le cache, les consommateurs lisent (v1.6.5)

Page d'accueil et /tendances lisent uniquement le cache trending_{period}.json
produit par le flux RSS /trending?period=…. Aucun parsing de logs en dehors du
flux RSS. Rubrique renommée "Meilleures audiences · 1 heure".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 18:19:10 +02:00
parent d0b486f11c
commit e19d20ca17
5 changed files with 12 additions and 21 deletions
+1 -11
View File
@@ -3453,22 +3453,12 @@ switch ($action) {
$allPostsMap = array_column($allPosts, null, 'uuid');
$_slugMap = array_column($allPosts, null, 'slug');
// Tendances 1 h — logs Apache (visiteurs uniques, cache 12 min)
require_once BASE_PATH . '/src/TrendingParser.php';
// Tendances 1 h — lecture seule du cache généré par /trending?period=1h
$_trendCache = DATA_PATH . '/_cache/trending_1h.json';
$_trendPaths = null;
if (file_exists($_trendCache) && (time() - filemtime($_trendCache)) < 720) {
$_trendPaths = json_decode((string) file_get_contents($_trendCache), true) ?: null;
}
if ($_trendPaths === null) {
$_tp = new TrendingParser('/var/log/apache2', apacheAccessLog());
if ($_tp->isReadable()) {
$_trendPaths = $_tp->top(time() - 3600, 20);
@mkdir(DATA_PATH . '/_cache', 0755, true);
@file_put_contents($_trendCache, json_encode($_trendPaths));
}
unset($_tp);
}
if (!empty($_trendPaths)) {
foreach ($_trendPaths as $_path => $_cnt) {
if (count($popularPosts) >= 6) {