feat: admin dashboard widgets
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user