feat: display new and pending feedbacks on admin dashboard

This commit is contained in:
Björn Fromme
2023-12-06 18:14:49 +01:00
parent 62d8d4d253
commit 7824153836
3 changed files with 53 additions and 10 deletions
+19 -10
View File
@@ -21,21 +21,30 @@ class FeedbackRepository extends ServiceEntityRepository
parent::__construct($registry, Feedback::class);
}
public function save(Feedback $entity, bool $flush = false): void
public function getNew(int $limit = 5): array
{
$this->getEntityManager()->persist($entity);
$qb = $this->createQueryBuilder('feedback');
if ($flush) {
$this->getEntityManager()->flush();
}
return $qb
->select('feedback', 'teamer')
->innerJoin('feedback.teamer', 'teamer')
->orderBy('feedback.createdAt', 'DESC')
->setMaxResults($limit)
->getQuery()
->getResult()
;
}
public function remove(Feedback $entity, bool $flush = false): void
public function getCountByStatus(string $status): int
{
$this->getEntityManager()->remove($entity);
$qb = $this->createQueryBuilder('feedback');
if ($flush) {
$this->getEntityManager()->flush();
}
return $qb
->select($qb->expr()->count('feedback'))
->where($qb->expr()->eq('feedback.status', ':status'))
->setParameter('status', $status)
->getQuery()
->getSingleScalarResult()
;
}
}