1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Itkg\DelayEventBundle\Repository; |
4
|
|
|
|
5
|
|
|
use Doctrine\ODM\MongoDB\DocumentRepository; |
6
|
|
|
use Itkg\DelayEventBundle\Model\Event; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class EventRepository |
10
|
|
|
*/ |
11
|
|
|
class EventRepository extends DocumentRepository |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @param bool $failed |
15
|
|
|
* @param array $eventTypeIncluded |
16
|
|
|
* @param array $eventTypeExcluded |
17
|
|
|
* @param string|null $groupFieldIdentifier |
18
|
|
|
* @return Event |
19
|
|
|
*/ |
20
|
|
|
public function findFirstTodoEvent($failed = false, array $eventTypeIncluded = [], array $eventTypeExcluded = [], $groupFieldIdentifier = null) |
21
|
|
|
{ |
22
|
|
|
$qb = $this->createQueryBuilder(); |
23
|
|
|
$qb->field('failed')->equals($failed); |
24
|
|
|
|
25
|
|
|
if (!empty($eventTypeIncluded)) { |
26
|
|
|
$qb->field('originalName')->in($eventTypeIncluded); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
if (!empty($eventTypeExcluded)) { |
30
|
|
|
$qb->field('originalName')->notIn($eventTypeExcluded); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
if (null !== $groupFieldIdentifier) { |
34
|
|
|
$qb->field('groupFieldIdentifier')->equals($groupFieldIdentifier); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
$qb->sort('createdAt', 'asc'); |
38
|
|
|
|
39
|
|
|
return $qb->getQuery()->getSingleResult(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param array $includedEvents |
44
|
|
|
* @param array $excludedEvents |
45
|
|
|
* |
46
|
|
|
* @return array |
47
|
|
|
*/ |
48
|
|
|
public function findDistinctFieldGroupIdentifierByChannel(array $includedEvents, array $excludedEvents) |
49
|
|
|
{ |
50
|
|
|
$qb = $this->createQueryBuilder(); |
51
|
|
|
$qb->distinct('groupFieldIdentifier'); |
52
|
|
|
$qb->field('failed')->equals(false); |
53
|
|
|
|
54
|
|
|
if (!empty($includedEvents)) { |
55
|
|
|
$qb->field('originalName')->in($includedEvents); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if (!empty($excludedEvents)) { |
59
|
|
|
$qb->field('originalName')->notIn($excludedEvents); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $qb->getQuery()->execute(); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|