feat: admin dashboard widgets

This commit is contained in:
Björn Fromme
2026-08-25 16:31:45 +02:00
parent 578a21d327
commit 4e6aaba9ff
17 changed files with 808 additions and 6 deletions
+34
View File
@@ -8,6 +8,7 @@ use App\Entity\Groups\AccommodationBooking;
use App\Entity\User;
use App\Form\Model\Filter\UserFilterDto;
use App\Repository\Filter\AppliesListFiltersTrait;
use App\Security\Role;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
@@ -88,4 +89,37 @@ class UserRepository extends ServiceEntityRepository
->addOrderBy('u.email')
;
}
/**
* The accounts carrying a nomination nobody has approved yet.
*
* Same reasoning as findGroupsStaff(): the roles are a JSON array column and no
* JSON_CONTAINS is registered, so each needle carries its quotes to stay anchored to a whole
* array entry. The markers are spelled out one by one rather than matched as '%_PENDING"%'
* because "_" is a single-character wildcard in LIKE, which would match more than markers.
*
* @return User[]
*/
public function findWithPendingRoles(int $limit): array
{
$qb = $this->createQueryBuilder('u');
$orX = $qb->expr()->orX();
foreach (Role::ADMINISTRATIVE as $index => $role) {
$parameter = 'pending'.$index;
$orX->add('u.roles LIKE :'.$parameter);
$qb->setParameter($parameter, '%"'.Role::pending($role).'"%');
}
/** @var User[] $users */
$users = $qb
->andWhere($orX)
->orderBy('u.lastLoginAt', 'DESC')
->setMaxResults($limit)
->getQuery()
->getResult()
;
return $users;
}
}