From c31480886cd4501bd22e3b36ef2f4337cf47314b Mon Sep 17 00:00:00 2001 From: soufiane Date: Fri, 28 Nov 2025 15:06:44 +0100 Subject: [PATCH] fix: include inactive users in draw eligible participants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users who deleted their account (is_active=false) should still be eligible for the grand prize draw if they have validated tickets. đŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/controllers/draw.controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/controllers/draw.controller.js b/src/controllers/draw.controller.js index 642819d6..0ee370c8 100644 --- a/src/controllers/draw.controller.js +++ b/src/controllers/draw.controller.js @@ -13,6 +13,7 @@ export const getEligibleParticipants = asyncHandler(async (req, res) => { // RequĂȘte pour obtenir les utilisateurs Ă©ligibles // Pour le tirage au sort du gros lot, tous les participants ont une chance Ă©gale + // Note: Les utilisateurs inactifs (compte supprimĂ©) sont inclus s'ils ont des tickets validĂ©s const query = ` SELECT u.id, @@ -20,6 +21,7 @@ export const getEligibleParticipants = asyncHandler(async (req, res) => { u.first_name, u.last_name, u.is_verified, + u.is_active, u.created_at, COALESCE(COUNT(DISTINCT t.id), 0) as tickets_played, COALESCE(COUNT(DISTINCT CASE WHEN t.status = 'CLAIMED' THEN t.id END), 0) as prizes_won @@ -27,7 +29,7 @@ export const getEligibleParticipants = asyncHandler(async (req, res) => { LEFT JOIN tickets t ON u.id = t.user_id AND t.played_at IS NOT NULL WHERE u.role = 'CLIENT' ${verified === 'true' ? 'AND u.is_verified = TRUE' : ''} - GROUP BY u.id, u.email, u.first_name, u.last_name, u.is_verified, u.created_at + GROUP BY u.id, u.email, u.first_name, u.last_name, u.is_verified, u.is_active, u.created_at ${parseInt(minTickets) > 0 ? 'HAVING COUNT(DISTINCT t.id) >= $1' : ''} ORDER BY u.created_at ASC `;