-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathActivityRepository.php
More file actions
68 lines (62 loc) · 1.93 KB
/
ActivityRepository.php
File metadata and controls
68 lines (62 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?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()
;
}
}