From 40836a2ee3bb5ea55da2e019536744ccada0c0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20S=C3=A1nchez?= Date: Thu, 13 Jun 2024 22:43:56 -0600 Subject: [PATCH] added set --- services/user.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/services/user.ts b/services/user.ts index 9007df2..c071b1c 100644 --- a/services/user.ts +++ b/services/user.ts @@ -196,21 +196,22 @@ export async function getUserSkillsById(id: string) { and(eq(userSkill.userId, id), eq(userSkill.kind, "AREA_OF_OPPORTUNITY")), ); - const strengthsSet = strengths.filter((s) => { - const set = new Set(); - if (set.has(s.name)) return false; - set.add(s.name); + const strengthsSet = new Set(); + const uniqueStrengths = strengths.filter((s) => { + if (strengthsSet.has(s.name)) return false; + strengthsSet.add(s.name); return true; }); - const areasOppSet = areasOfOportunity.filter((s) => { - const set = new Set(); - if (set.has(s.name)) return false; - set.add(s.name); + + const areasOppSet = new Set(); + const uniqueAreasOfOpportunity = areasOfOportunity.filter((s) => { + if (areasOppSet.has(s.name)) return false; + areasOppSet.add(s.name); return true; }); const traits = { - strengths: strengthsSet, - areasOfOportunity: areasOppSet, + strengths: uniqueStrengths, + areasOfOportunity: uniqueAreasOfOpportunity, }; return traits; }