feat: admin dashboard widgets

This commit is contained in:
Björn Fromme committed 2026-08-25 16:31:45 +02:00
1 parent 578a21d327
commit 4e6aaba9ff
17 files changed
+808 -6

No files matched your search

+19
View File
@@ -82,4 +82,23 @@ class LogEntryRepository extends ServiceEntityRepository
->getQuery()
->getResult();
}
/**
* The most recent entries, newest first — the dashboard's "what just happened" excerpt.
*
* @return LogEntry[]
*/
public function findLatest(int $limit): array
{
/** @var LogEntry[] $entries */
$entries = $this->createQueryBuilder('log_entry')
->orderBy('log_entry.createdAt', 'DESC')
->addOrderBy('log_entry.id', 'DESC')
->setMaxResults($limit)
->getQuery()
->getResult()
;
return $entries;
}
}
+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;
}
}