mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-03-31 17:15:38 +00:00
68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Repository;
|
|
|
|
use App\Entity\Activity;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
/**
|
|
* @extends ServiceEntityRepository<Activity>
|
|
*
|
|
* @method Activity|null find($id, $lockMode = null, $lockVersion = null)
|
|
* @method Activity|null findOneBy(array $criteria, array $orderBy = null)
|
|
* @method Activity[] findAll()
|
|
* @method Activity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
*/
|
|
class ActivityRepository extends ServiceEntityRepository
|
|
{
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, Activity::class);
|
|
}
|
|
|
|
public function findActivitiesTotal(
|
|
array $whitelist
|
|
): int
|
|
{
|
|
return $this->createQueryBuilder('a')
|
|
->select('count(a.id)')
|
|
->where('a.event IN (:event)')
|
|
->setParameter(':event', $whitelist)
|
|
->getQuery()
|
|
->getSingleScalarResult()
|
|
;
|
|
}
|
|
|
|
public function findActivitiesTotalByUserId(
|
|
int $userId,
|
|
array $whitelist
|
|
): int
|
|
{
|
|
return $this->createQueryBuilder('a')
|
|
->select('count(a.id)')
|
|
->where('a.userId = :userId')
|
|
->andWhere('a.event IN (:event)')
|
|
->setParameter(':userId', $userId)
|
|
->setParameter(':event', $whitelist)
|
|
->getQuery()
|
|
->getSingleScalarResult()
|
|
;
|
|
}
|
|
|
|
public function findActivitiesTotalByTorrentId(
|
|
int $torrentId,
|
|
array $whitelist
|
|
): int
|
|
{
|
|
return $this->createQueryBuilder('a')
|
|
->select('count(a.id)')
|
|
->where('a.torrentId = :torrentId')
|
|
->andWhere('a.event IN (:event)')
|
|
->setParameter(':torrentId', $torrentId)
|
|
->setParameter(':event', $whitelist)
|
|
->getQuery()
|
|
->getSingleScalarResult()
|
|
;
|
|
}
|
|
}
|