|
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\Component\Trade\TradeEnum; |
|
|
|
|
|
|
10
|
|
|
use Stu\Orm\Entity\BasicTrade; |
|
11
|
|
|
use Stu\Orm\Entity\TradeLicense; |
|
12
|
|
|
use Stu\Orm\Entity\TradePost; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @extends EntityRepository<BasicTrade> |
|
16
|
|
|
*/ |
|
17
|
|
|
final class BasicTradeRepository extends EntityRepository implements BasicTradeRepositoryInterface |
|
18
|
|
|
{ |
|
19
|
|
|
#[Override] |
|
20
|
|
|
public function prototype(): BasicTrade |
|
21
|
|
|
{ |
|
22
|
|
|
return new BasicTrade(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
#[Override] |
|
26
|
|
|
public function save(BasicTrade $basicTrade): void |
|
27
|
|
|
{ |
|
28
|
|
|
$em = $this->getEntityManager(); |
|
29
|
|
|
|
|
30
|
|
|
$em->persist($basicTrade); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
1 |
|
#[Override] |
|
34
|
|
|
public function getBasicTrades(int $userId): array |
|
35
|
|
|
{ |
|
36
|
1 |
|
return $this->getEntityManager()->createQuery( |
|
37
|
1 |
|
sprintf( |
|
38
|
1 |
|
'SELECT bt FROM %1$s bt |
|
39
|
|
|
WHERE bt.faction_id IN (SELECT tp.trade_network |
|
40
|
|
|
FROM %2$s tl |
|
41
|
|
|
JOIN %3$s tp WITH tl.posts_id = tp.id |
|
42
|
|
|
WHERE tl.user_id = :userId |
|
43
|
|
|
GROUP BY tp.trade_network) |
|
44
|
|
|
AND bt.date_ms = (SELECT max(bt2.date_ms) FROM %1$s bt2 |
|
45
|
|
|
WHERE bt.faction_id = bt2.faction_id AND bt.commodity_id = bt2.commodity_id) |
|
46
|
1 |
|
ORDER BY bt.commodity_id ASC', |
|
47
|
1 |
|
BasicTrade::class, |
|
48
|
1 |
|
TradeLicense::class, |
|
49
|
1 |
|
TradePost::class |
|
50
|
1 |
|
) |
|
51
|
1 |
|
)->setParameters([ |
|
52
|
1 |
|
'userId' => $userId |
|
53
|
1 |
|
])->getResult(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
#[Override] |
|
57
|
|
|
public function getByUniqId(string $uniqId): ?BasicTrade |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->findOneBy([ |
|
60
|
|
|
'uniqid' => $uniqId |
|
61
|
|
|
]); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
#[Override] |
|
65
|
|
|
public function isNewest(BasicTrade $basicTrade): bool |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->getEntityManager()->createQuery( |
|
68
|
|
|
sprintf( |
|
69
|
|
|
'SELECT count(bt.id) FROM %s bt |
|
70
|
|
|
WHERE bt.faction_id = :factionId |
|
71
|
|
|
AND bt.commodity_id = :commodityId |
|
72
|
|
|
AND bt.date_ms > :myDate', |
|
73
|
|
|
BasicTrade::class |
|
74
|
|
|
) |
|
75
|
|
|
)->setParameters([ |
|
76
|
|
|
'factionId' => $basicTrade->getFaction()->getId(), |
|
77
|
|
|
'commodityId' => $basicTrade->getCommodity()->getId(), |
|
78
|
|
|
'myDate' => $basicTrade->getDate() |
|
79
|
|
|
])->getSingleScalarResult() === 0; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
#[Override] |
|
83
|
|
|
public function getLatestRates(BasicTrade $basicTrade): array |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->getEntityManager() |
|
86
|
|
|
->createQuery( |
|
87
|
|
|
sprintf( |
|
88
|
|
|
'SELECT bt FROM %s bt |
|
89
|
|
|
WHERE bt.faction_id = :factionId |
|
90
|
|
|
AND bt.commodity_id = :commodityId |
|
91
|
|
|
ORDER BY bt.date_ms DESC', |
|
92
|
|
|
BasicTrade::class |
|
93
|
|
|
) |
|
94
|
|
|
) |
|
95
|
|
|
->setParameters([ |
|
96
|
|
|
'factionId' => $basicTrade->getFaction()->getId(), |
|
97
|
|
|
'commodityId' => $basicTrade->getCommodity()->getId() |
|
98
|
|
|
]) |
|
99
|
|
|
->setMaxResults(TradeEnum::BASIC_TRADE_LATEST_RATE_AMOUNT) |
|
100
|
|
|
->getResult(); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
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