From d038046bf1ce3c0017c2cd82343f1ae3d61a5c3b Mon Sep 17 00:00:00 2001 From: Freek Bes Date: Mon, 18 Nov 2024 14:03:29 +0100 Subject: [PATCH] fix: duplicate users in assigning custom points csv reports missing users in database --- src/routes/admin/points.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/admin/points.ts b/src/routes/admin/points.ts index fd775fa..32d194f 100644 --- a/src/routes/admin/points.ts +++ b/src/routes/admin/points.ts @@ -516,8 +516,10 @@ export const setupAdminPointsRoutes = function(app: Express, prisma: PrismaClien login: true, }, }); - if (users.length !== loginsArray.length) { - const missingLogins = loginsArray.filter((login: string) => !users.find((user: any) => user.login === login)); + // Get the list of unique logins in loginsArray + const uniqueUsers = Array.from(new Set(loginsArray)); + if (users.length !== uniqueUsers.length) { + const missingLogins = uniqueUsers.filter((login: string) => !users.find((user: any) => user.login === login)); console.log(`The following logins have not been found in the coalition system: ${missingLogins.join(', ')}`); return res.status(400).send(`The following logins have not been found in the coalition system: ${missingLogins.join(', ')}`); }