From e8bca6a502cef58394558b3bc3d11abde16efcc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 23 May 2025 15:52:11 +0200 Subject: [PATCH] Do not sync user which are enabled with UserGroup related to UserJob. Updated SQL queries to include checks for user.enabled status, ensuring proper handling of both enabled and null states. This improves the synchronization logic by aligning it with user activity and account status conditions. --- .../Service/UserGroup/UserGroupRelatedToUserJobSync.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Service/UserGroup/UserGroupRelatedToUserJobSync.php b/src/Bundle/ChillMainBundle/Service/UserGroup/UserGroupRelatedToUserJobSync.php index d54f089d2..fd030bb16 100644 --- a/src/Bundle/ChillMainBundle/Service/UserGroup/UserGroupRelatedToUserJobSync.php +++ b/src/Bundle/ChillMainBundle/Service/UserGroup/UserGroupRelatedToUserJobSync.php @@ -87,8 +87,8 @@ final readonly class UserGroupRelatedToUserJobSync implements UserGroupRelatedTo AND chill_main_user_group_user.user_id = u.id AND jh.user_id = u.id AND tsrange(jh.startdate, jh.enddate) @> localtimestamp -- only when the user's jobid is different than the user_group id - AND ug.userjob_id IS NOT NULL - AND jh.job_id <> ug.userjob_id + -- or where the user.enabled is null + AND ((ug.userjob_id IS NOT NULL AND jh.job_id <> ug.userjob_id) OR u.enabled IS NULL) SQL; $result = $connection->executeQuery($sql); @@ -103,7 +103,8 @@ final readonly class UserGroupRelatedToUserJobSync implements UserGroupRelatedTo SELECT cmug.id, jh.user_id FROM chill_main_user_group cmug JOIN chill_main_user_job_history jh ON jh.job_id = cmug.userjob_id AND tsrange(jh.startdate, jh.enddate) @> localtimestamp - WHERE cmug.userjob_id IS NOT NULL + JOIN users u ON u.id = jh.user_id + WHERE cmug.userjob_id IS NOT NULL AND u.enabled IS TRUE ON CONFLICT DO NOTHING SQL;