|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Orm\Repository; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\EntityRepository; |
|
8
|
|
|
use Override; |
|
|
|
|
|
|
9
|
|
|
use Stu\Orm\Entity\Alliance; |
|
10
|
|
|
use Stu\Orm\Entity\AllianceRelation; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @extends EntityRepository<AllianceRelation> |
|
14
|
|
|
*/ |
|
15
|
|
|
final class AllianceRelationRepository extends EntityRepository implements AllianceRelationRepositoryInterface |
|
16
|
|
|
{ |
|
17
|
|
|
#[Override] |
|
18
|
|
|
public function prototype(): AllianceRelation |
|
19
|
|
|
{ |
|
20
|
|
|
return new AllianceRelation(); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
#[Override] |
|
24
|
|
|
public function save(AllianceRelation $post): void |
|
25
|
|
|
{ |
|
26
|
|
|
$em = $this->getEntityManager(); |
|
27
|
|
|
|
|
28
|
|
|
$em->persist($post); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
#[Override] |
|
32
|
|
|
public function delete(AllianceRelation $post): void |
|
33
|
|
|
{ |
|
34
|
|
|
$em = $this->getEntityManager(); |
|
35
|
|
|
|
|
36
|
|
|
$em->remove($post); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
#[Override] |
|
40
|
|
|
public function truncateByAlliances(Alliance $alliance, Alliance $opponent): void |
|
41
|
|
|
{ |
|
42
|
|
|
$this->getEntityManager() |
|
43
|
|
|
->createQuery( |
|
44
|
|
|
sprintf( |
|
45
|
|
|
'DELETE FROM %s ar WHERE ar.alliance IN (:alliance,:opponent) AND ar.opponent IN (:alliance,:opponent)', |
|
46
|
|
|
AllianceRelation::class |
|
47
|
|
|
) |
|
48
|
|
|
) |
|
49
|
|
|
->setParameters([ |
|
50
|
|
|
'alliance' => $alliance, |
|
51
|
|
|
'opponent' => $opponent |
|
52
|
|
|
]) |
|
53
|
|
|
->execute(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
#[Override] |
|
57
|
|
|
public function getPendingCountByAlliances(int $allianceId, int $opponentId): int |
|
58
|
|
|
{ |
|
59
|
|
|
return (int) $this->getEntityManager() |
|
60
|
|
|
->createQuery( |
|
61
|
|
|
sprintf( |
|
62
|
|
|
'SELECT COUNT(ar.id) FROM %s ar WHERE ar.date = :date AND ( |
|
63
|
|
|
ar.alliance_id IN (:allianceId,:opponentId) AND ar.recipient IN (:allianceId,:opponentId) |
|
64
|
|
|
)', |
|
65
|
|
|
AllianceRelation::class |
|
66
|
|
|
) |
|
67
|
|
|
) |
|
68
|
|
|
->setParameters([ |
|
69
|
|
|
'date' => 0, |
|
70
|
|
|
'allianceId' => $allianceId, |
|
71
|
|
|
'opponentId' => $opponentId |
|
72
|
|
|
]) |
|
73
|
|
|
->getSingleScalarResult(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
#[Override] |
|
77
|
|
|
public function getByAlliancePair(int $allianceId, int $opponentId): array |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->getEntityManager() |
|
80
|
|
|
->createQuery( |
|
81
|
|
|
sprintf( |
|
82
|
|
|
'SELECT ar FROM %s ar WHERE ar.alliance_id IN (:allianceId,:opponentId) AND ar.recipient IN (:allianceId,:opponentId)', |
|
83
|
|
|
AllianceRelation::class |
|
84
|
|
|
) |
|
85
|
|
|
) |
|
86
|
|
|
->setParameters([ |
|
87
|
|
|
'allianceId' => $allianceId, |
|
88
|
|
|
'opponentId' => $opponentId |
|
89
|
|
|
]) |
|
90
|
|
|
->getResult(); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
1 |
|
#[Override] |
|
95
|
|
|
public function getActiveByAlliance(int $allianceId): array |
|
96
|
|
|
{ |
|
97
|
1 |
|
return $this->getEntityManager() |
|
98
|
1 |
|
->createQuery( |
|
99
|
1 |
|
sprintf( |
|
100
|
1 |
|
'SELECT ar FROM %s ar |
|
101
|
|
|
WHERE ar.date > 0 AND (ar.alliance_id = :allianceId OR ar.recipient = :allianceId) |
|
102
|
1 |
|
ORDER BY ar.id ASC', |
|
103
|
1 |
|
AllianceRelation::class |
|
104
|
1 |
|
) |
|
105
|
1 |
|
) |
|
106
|
1 |
|
->setParameters([ |
|
107
|
1 |
|
'allianceId' => $allianceId |
|
108
|
1 |
|
]) |
|
109
|
1 |
|
->getResult(); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
1 |
|
#[Override] |
|
113
|
|
|
public function getByAlliance(int $allianceId): array |
|
114
|
|
|
{ |
|
115
|
1 |
|
return $this->getEntityManager() |
|
116
|
1 |
|
->createQuery( |
|
117
|
1 |
|
sprintf( |
|
118
|
1 |
|
'SELECT ar FROM %s ar WHERE ar.alliance_id = :allianceId OR ar.recipient = :allianceId', |
|
119
|
1 |
|
AllianceRelation::class |
|
120
|
1 |
|
) |
|
121
|
1 |
|
) |
|
122
|
1 |
|
->setParameters([ |
|
123
|
1 |
|
'allianceId' => $allianceId |
|
124
|
1 |
|
]) |
|
125
|
1 |
|
->getResult(); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
#[Override] |
|
129
|
|
|
public function getActiveByAlliancePair(int $allianceId, int $opponentId): ?AllianceRelation |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->getEntityManager() |
|
132
|
|
|
->createQuery( |
|
133
|
|
|
sprintf( |
|
134
|
|
|
'SELECT ar FROM %s ar WHERE ar.date > 0 AND ar.alliance_id IN (:allianceId,:opponentId) AND ar.recipient IN (:allianceId,:opponentId)', |
|
135
|
|
|
AllianceRelation::class |
|
136
|
|
|
) |
|
137
|
|
|
) |
|
138
|
|
|
->setParameters([ |
|
139
|
|
|
'allianceId' => $allianceId, |
|
140
|
|
|
'opponentId' => $opponentId |
|
141
|
|
|
]) |
|
142
|
|
|
->getOneOrNullResult(); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
|
|
146
|
|
|
#[Override] |
|
147
|
|
|
public function getActiveByTypeAndAlliancePair(array $typeIds, int $allianceId, int $opponentId): ?AllianceRelation |
|
148
|
|
|
{ |
|
149
|
|
|
return $this->getEntityManager() |
|
150
|
|
|
->createQuery( |
|
151
|
|
|
sprintf( |
|
152
|
|
|
'SELECT ar FROM %s ar WHERE ar.type IN (:typeIds) AND ar.date > 0 AND ar.alliance_id IN (:allianceId,:opponentId) AND ar.recipient IN (:allianceId,:opponentId)', |
|
153
|
|
|
AllianceRelation::class |
|
154
|
|
|
) |
|
155
|
|
|
) |
|
156
|
|
|
->setParameters([ |
|
157
|
|
|
'allianceId' => $allianceId, |
|
158
|
|
|
'opponentId' => $opponentId, |
|
159
|
|
|
'typeIds' => $typeIds |
|
160
|
|
|
]) |
|
161
|
|
|
->getOneOrNullResult(); |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths