Add images in Finding index

This commit is contained in:
Nicolò P 2025-09-02 09:59:30 +02:00
parent f35be9c845
commit 386653b6bf
2 changed files with 7 additions and 3 deletions

View File

@ -16,6 +16,7 @@ class FindingController extends AbstractController
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Finding::class);
$imgRepo = $em->getRepository(Image::class);
$findings = $repo->findBy([], ['label' => 'ASC']);
@ -23,6 +24,12 @@ class FindingController extends AbstractController
$coords = $repo->coordinates($finding->getId());
$finding->setLat($coords['lat']);
$finding->setLng($coords['lng']);
// TODO N + 1!!
$images = $imgRepo->findBy(
['finding' => $finding->getId()],
['sequence' => 'ASC']
);
$finding->setImages($images);
$findings[$key] = $finding;
}

View File

@ -16,7 +16,6 @@ class ReuseController extends AbstractController
public function index(EntityManagerInterface $em): JsonResponse
{
$repo = $em->getRepository(Reuse::class);
//$repoBib = $em->getRepository(Bibliography::class);
$repoImg = $em->getRepository(Image::class);
$records = $repo->findBy([], ['label' => 'ASC']);
@ -26,8 +25,6 @@ class ReuseController extends AbstractController
$id = $record->getId();
$record->setLat($repo->coordinates($id)['lat']);
$record->setLng($repo->coordinates($id)['lng']);
//$biblio = $repoBib->findAllByNotConserved($id);
//$record->setBibliographies($biblio);
$images = $repoImg->findBy(
['reuse' => $record->getId()],
['sequence' => 'ASC']