From 3417aa8207963cd7eae4b88bf09fc7fb9211fef3 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 15 Nov 2021 12:00:42 +0100 Subject: [PATCH 1/2] person: do not suggest the current household of the person --- .../Controller/HouseholdApiController.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php index 11e41ba29..3f3e04cb3 100644 --- a/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/HouseholdApiController.php @@ -47,13 +47,22 @@ class HouseholdApiController extends ApiController $count = $this->householdRepository->countByAccompanyingPeriodParticipation($person); $paginator = $this->getPaginatorFactory()->create($count); - if ($count === 0) { - $households = []; - } else { - $households = $this->householdRepository->findByAccompanyingPeriodParticipation($person, + $households = []; + if ($count !== 0) { + $allHouseholds = $this->householdRepository->findByAccompanyingPeriodParticipation($person, $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber()); - } + $currentHouseholdPerson = $person->getCurrentHousehold(); + foreach ($allHouseholds as $h) { + if ($h !== $currentHouseholdPerson) { + array_push($households, $h); + } + } + if (null !== $currentHouseholdPerson) { + $count = $count - 1; + $paginator = $this->getPaginatorFactory()->create($count); + } + } $collection = new Collection($households, $paginator); return $this->json($collection, Response::HTTP_OK, [], From bfc25c50b926905e5793081c659321335d7a81f1 Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 15 Nov 2021 12:03:31 +0100 Subject: [PATCH 2/2] upd CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66de80f48..b2b969c66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to ## Unreleased +* [person]: do not suggest the current household of the person (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/51) + * unnecessary whitespace removed from person banner after person-id + double parentheses removed (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/290) * [person]: delete accompanying period work, including related objects (cascade) (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/36) * [address]: Display of incomplete address adjusted.