ApiCallRepository::loadReadyCalls()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 15
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
namespace Tarioch\EveapiFetcherBundle\Entity;
3
4
use Doctrine\ORM\EntityRepository;
5
6
class ApiCallRepository extends EntityRepository
7
{
8
9
    public function loadReadyCalls()
10
    {
11
        $qb = $this->createQueryBuilder('ac');
12
        $q = $qb->select('ac', 'a')
13
            ->join('ac.api', 'a')
14
            ->where(
15
                'ac.active = true
16
                and (ac.cachedUntil is null or ac.cachedUntil <= :date)
17
                and (ac.earliestNextCall is null or ac.earliestNextCall <= :date)'
18
            )
19
            ->setParameter('date', new \DateTime('now', new \DateTimeZone('UTC')))
20
            ->getQuery();
21
22
        return $q->getResult();
23
    }
24
25
    public function findNormalCallsByKey(ApiKey $key)
26
    {
27
        $qb = $this->createQueryBuilder('ac');
28
        $q = $qb->select('ac', 'a')
29
            ->join('ac.api', 'a')
30
            ->where(
31
                'ac.key = :key
32
                and a.mask is not null'
33
            )
34
            ->setParameter('key', $key)
35
            ->getQuery();
36
37
        return $q->getResult();
38
    }
39
}
40