Skip to content

Commit 390dcda

Browse files
committed
display system events on event map
1 parent e303c99 commit 390dcda

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Orm/Repository/HistoryRepository.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Stu\Orm\Entity\History;
1111
use Stu\Orm\Entity\Layer;
1212
use Stu\Orm\Entity\Map;
13+
use Stu\Orm\Entity\StarSystemMap;
1314

1415
/**
1516
* @extends EntityRepository<History>
@@ -124,15 +125,20 @@ public function getAmountIndexedByLocationId(Layer $layer, int $dateThreshold):
124125
return $this->getEntityManager()
125126
->createQuery(
126127
sprintf(
127-
'SELECT m, COUNT(h.id) AS amount
128-
FROM %s h
129-
JOIN %s m WITH h.location = m
128+
'SELECT m, COUNT(distinct h.id) + COUNT(distinct sm_h.id) AS amount
129+
FROM %s m
130+
JOIN %s h WITH h.location = m
131+
LEFT JOIN m.starSystem mss
132+
LEFT JOIN %s ssm WITH ssm.starSystem = mss
133+
LEFT JOIN %s sm_h WITH sm_h.location = ssm
130134
WHERE m.layer = :layer
131-
AND h.location IS NOT NULL
132135
AND h.date >= :dateThreshold
136+
AND (sm_h.date IS NULL OR sm_h.date >= :dateThreshold)
133137
GROUP BY m',
134-
History::class,
135-
Map::class
138+
Map::class,
139+
History::class,
140+
StarSystemMap::class,
141+
History::class
136142
)
137143
)
138144
->setParameters([

0 commit comments

Comments
 (0)