diff --git a/src/Command/QualityCheckArticlesCommand.php b/src/Command/QualityCheckArticlesCommand.php index dfdc123..bf66df4 100644 --- a/src/Command/QualityCheckArticlesCommand.php +++ b/src/Command/QualityCheckArticlesCommand.php @@ -49,7 +49,7 @@ class QualityCheckArticlesCommand extends Command $content = $article->getContent(); // No empty title - if (empty($article->getTitle()) || strtolower($article->getTitle()) === 'test') { + if (empty($article->getTitle()) || strtolower($article->getTitle()) === 'test' || strtolower($article->getTitle()) === 'step counter') { return false; } diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index 4a6b875..802cc78 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Contracts\Cache\CacheInterface; use Psr\Log\LoggerInterface; +use Symfony\Contracts\Cache\ItemInterface; class DefaultController extends AbstractController { @@ -26,28 +27,21 @@ class DefaultController extends AbstractController /** * @throws Exception - * @throws InvalidArgumentException */ #[Route('/', name: 'home')] public function index(): Response { - // get latest articles - $q = new Query(); - $q->setSize(12); - $q->setSort(['createdAt' => ['order' => 'desc']]); - $latest = $this->finder->find($q); - // get newsroom index, loop over categories, pick top three from each and display in sections - $mag = $this->redisCache->get('magazine-newsroom-magazine-by-newsroom', function (){ - return null; - }); - $tags = $mag->getTags(); - - $cats = array_filter($tags, function($tag) { - return ($tag[0] === 'a'); + $cacheKey = 'home-latest-articles'; + $latest = $this->redisCache->get($cacheKey, function (ItemInterface $item) { + $item->expiresAfter(13600); // about 4 hours + // get latest articles + $q = new Query(); + $q->setSize(50); + $q->setSort(['createdAt' => ['order' => 'desc']]); + return $this->finder->find($q); }); return $this->render('home.html.twig', [ - 'indices' => array_values($cats), 'latest' => $latest ]); }