From 4a056d57347b19b3d404cc878df759e4926cb9f8 Mon Sep 17 00:00:00 2001 From: Joan Reyero Date: Tue, 7 Nov 2023 15:10:32 +0100 Subject: [PATCH] Sort merge suggestions by confidence (#1826) --- backend/src/database/repositories/memberRepository.ts | 2 +- backend/src/services/__tests__/tenantService.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/database/repositories/memberRepository.ts b/backend/src/database/repositories/memberRepository.ts index 8bb16aae00..da471d8f3b 100644 --- a/backend/src/database/repositories/memberRepository.ts +++ b/backend/src/database/repositories/memberRepository.ts @@ -268,7 +268,7 @@ class MemberRepository { AND ms."segmentId" IN (:segmentIds) ) AS "membersToMerge" ORDER BY - "membersToMerge"."joinedAt" DESC + "membersToMerge"."similarity" DESC LIMIT :limit OFFSET :offset `, { diff --git a/backend/src/services/__tests__/tenantService.test.ts b/backend/src/services/__tests__/tenantService.test.ts index 95155e4d4a..8ac680bbfc 100644 --- a/backend/src/services/__tests__/tenantService.test.ts +++ b/backend/src/services/__tests__/tenantService.test.ts @@ -83,8 +83,8 @@ describe('TenantService tests', () => { const member3 = await memberService.upsert(memberToCreate3) let member4 = await memberService.upsert(memberToCreate4) - await memberService.addToMerge([{ members: [member1.id, member2.id], similarity: null }]) - await memberService.addToMerge([{ members: [member3.id, member4.id], similarity: null }]) + await memberService.addToMerge([{ members: [member1.id, member2.id], similarity: 1 }]) + await memberService.addToMerge([{ members: [member3.id, member4.id], similarity: 0.5 }]) member2 = await memberService.findById(member2.id) member4 = await memberService.findById(member4.id)