Keep track of discontinued items. That means items that were tracked, but then they were never updated.Added is discontinued badge.

This commit is contained in:
Krzysztof Płaczek
2025-02-15 11:33:24 +01:00
parent 7eb7bf3eb2
commit 81f9c863c7
7 changed files with 52 additions and 9 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace Krzysiej\RyobiCrawler\Controller;
use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use function Symfony\Component\Clock\now;
final class DiscontinuedController extends BaseController
{
#[Route('/discontinued', name: 'app_discontinued')]
public function __invoke(): Response
{
$products = Product::where('updated_at', '<', now()->format('Y-m-d'))
->orderByDesc('starred')
->orderByDesc('created_by')
->with(['currentPrice'])
->get();
return $this->render('productList.html.twig', ['products' => $products]);
}
}

View File

@@ -7,13 +7,14 @@ use Krzysiej\RyobiCrawler\Models\Product;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use function Symfony\Component\Clock\now;
final class NewController extends BaseController
{
#[Route('/new', name: 'app_new')]
public function __invoke(): Response
{
$date = (new \DateTime())->modify('-30 days')->format('Y-m-d');
$products = Product::where('created_at', '>', $date)
$products = Product::where('created_at', '>', now()->modify('-30 days')->format('Y-m-d'))
->orderByDesc('starred')
->orderByDesc('created_by')
->with(['currentPrice'])