feat: replace notifications with import status in profile dropdown
Remove the notification system entirely and show import progress directly in the user dropdown menu. Block new imports while one is already running. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -33,4 +33,27 @@ class ImportRepository extends ServiceEntityRepository
|
||||
['id' => $import->getId()]
|
||||
);
|
||||
}
|
||||
|
||||
public function findLatestForUser(\App\Entity\User $user): ?Import
|
||||
{
|
||||
return $this->createQueryBuilder('i')
|
||||
->andWhere('i.user = :user')
|
||||
->setParameter('user', $user)
|
||||
->orderBy('i.createdAt', 'DESC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
public function hasActiveImport(\App\Entity\User $user): bool
|
||||
{
|
||||
return (int) $this->createQueryBuilder('i')
|
||||
->select('COUNT(i.id)')
|
||||
->andWhere('i.user = :user')
|
||||
->andWhere('i.status IN (:statuses)')
|
||||
->setParameter('user', $user)
|
||||
->setParameter('statuses', [Import::STATUS_PENDING, Import::STATUS_PROCESSING])
|
||||
->getQuery()
|
||||
->getSingleScalarResult() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Notification;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Notification>
|
||||
*/
|
||||
class NotificationRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Notification::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Notification[]
|
||||
*/
|
||||
public function findRecentForUser(User $user, int $limit = 20): array
|
||||
{
|
||||
return $this->createQueryBuilder('n')
|
||||
->andWhere('n.user = :user')
|
||||
->setParameter('user', $user)
|
||||
->orderBy('n.createdAt', 'DESC')
|
||||
->setMaxResults($limit)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function countUnreadForUser(User $user): int
|
||||
{
|
||||
return $this->count(['user' => $user, 'read' => false]);
|
||||
}
|
||||
|
||||
public function markAllReadForUser(User $user): void
|
||||
{
|
||||
$this->createQueryBuilder('n')
|
||||
->update()
|
||||
->set('n.read', ':true')
|
||||
->where('n.user = :user')
|
||||
->andWhere('n.read = :false')
|
||||
->setParameter('true', true)
|
||||
->setParameter('false', false)
|
||||
->setParameter('user', $user)
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user