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;