From 7c9b4d02f6661c095f1d394b186c2cbf547b2378 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 18 Dec 2025 11:07:57 +0100 Subject: [PATCH] Fix ordering of social actions Actions with a closing date in the future should be considered as 'still open'. --- .../unreleased/Fixed-20251218-110722.yaml | 6 ++++++ .../AccompanyingPeriodWorkRepository.php | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 .changes/unreleased/Fixed-20251218-110722.yaml diff --git a/.changes/unreleased/Fixed-20251218-110722.yaml b/.changes/unreleased/Fixed-20251218-110722.yaml new file mode 100644 index 000000000..045211032 --- /dev/null +++ b/.changes/unreleased/Fixed-20251218-110722.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: 'Fix ordering of social actions: actions with a closing date in the future should be considered as ''still open''.' +time: 2025-12-18T11:07:22.699897317+01:00 +custom: + Issue: "481" + SchemaChange: No schema change diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php index df5ee6c66..d72084bdd 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkRepository.php @@ -100,9 +100,9 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository $rsm->addRootEntityFromClassMetadata(AccompanyingPeriodWork::class, 'w'); $sql = "SELECT {$rsm} FROM chill_person_accompanying_period_work w - LEFT JOIN chill_person_accompanying_period_work_referrer AS rw ON accompanyingperiodwork_id = w.id - AND (rw.enddate IS NULL OR rw.enddate > CURRENT_DATE) - WHERE accompanyingPeriod_id = :periodId"; + LEFT JOIN chill_person_accompanying_period_work_referrer AS rw ON accompanyingperiodwork_id = w.id + AND (rw.enddate IS NULL OR rw.enddate > CURRENT_DATE) + WHERE accompanyingPeriod_id = :periodId"; // implement filters @@ -136,11 +136,14 @@ class AccompanyingPeriodWorkRepository implements ObjectRepository } // set limit and offset - $sql .= " ORDER BY - CASE WHEN w.enddate IS NULL THEN '-infinity'::timestamp ELSE 'infinity'::timestamp END ASC, - w.startdate DESC, - w.enddate DESC, - w.id DESC"; + $sql .= ' ORDER BY + CASE + WHEN w.enddate IS NULL OR w.enddate > CURRENT_DATE THEN 0 + ELSE 1 + END ASC, + w.startdate DESC, + w.enddate DESC, + w.id DESC'; $sql .= ' LIMIT :limit OFFSET :offset';