|
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\MiningQueue; |
|
10
|
|
|
use Stu\Orm\Entity\MiningQueueInterface; |
|
11
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
12
|
|
|
use Stu\Orm\Entity\LocationMining; |
|
13
|
|
|
use Stu\Orm\Entity\LocationMiningInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @extends EntityRepository<LocationMining> |
|
17
|
|
|
*/ |
|
18
|
|
|
final class LocationMiningRepository extends EntityRepository implements LocationMiningRepositoryInterface |
|
19
|
|
|
{ |
|
20
|
|
|
public function prototype(): LocationMiningInterface |
|
21
|
|
|
{ |
|
22
|
|
|
return new LocationMining(); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function save(LocationMiningInterface $locationMining): void |
|
26
|
|
|
{ |
|
27
|
|
|
$em = $this->getEntityManager(); |
|
28
|
|
|
$em->persist($locationMining); |
|
29
|
|
|
$em->flush(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
#[Override] |
|
33
|
|
|
public function getMiningAtLocation(ShipInterface $ship): array |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->getEntityManager()->createQuery( |
|
36
|
|
|
sprintf( |
|
37
|
|
|
'SELECT ml FROM %s ml |
|
38
|
|
|
WHERE ml.location_id = :locationId', |
|
39
|
|
|
LocationMining::class |
|
40
|
|
|
) |
|
41
|
|
|
)->setParameters([ |
|
42
|
|
|
'locationId' => $ship->getLocation()->getId() |
|
43
|
|
|
])->getResult(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
#[Override] |
|
47
|
|
|
public function getMiningQueueAtLocation(ShipInterface $ship): ?MiningQueueInterface |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->getEntityManager()->createQuery( |
|
50
|
|
|
sprintf( |
|
51
|
|
|
'SELECT mq FROM %s mq |
|
52
|
|
|
WHERE mq.ship_id = :shipId', |
|
53
|
|
|
MiningQueue::class |
|
54
|
|
|
) |
|
55
|
|
|
)->setParameters([ |
|
56
|
|
|
'shipId' => $ship->getId() |
|
57
|
|
|
])->getOneOrNullResult(); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
#[Override] |
|
61
|
|
|
public function findById(int $id): ?LocationMiningInterface |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->find($id); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return LocationMiningInterface[] |
|
68
|
|
|
*/ |
|
69
|
|
|
public function findDepletedEntries(): array |
|
70
|
|
|
{ |
|
71
|
|
|
$twentyDaysAgo = time() - (20 * 24 * 60 * 60); |
|
72
|
|
|
|
|
73
|
|
|
return $this->getEntityManager()->createQuery( |
|
74
|
|
|
sprintf( |
|
75
|
|
|
'SELECT lm FROM %s lm |
|
76
|
|
|
WHERE lm.depleted_at < :twentyDaysAgo |
|
77
|
|
|
AND lm.actual_amount < lm.max_amount', |
|
78
|
|
|
LocationMining::class |
|
79
|
|
|
) |
|
80
|
|
|
)->setParameters([ |
|
81
|
|
|
'twentyDaysAgo' => $twentyDaysAgo |
|
82
|
|
|
])->getResult(); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
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