Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 0 additions & 326 deletions backend/src/bin/scripts/fix-auto-merged-orgs.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP TABLE IF EXISTS "activityTasks";
DROP TABLE IF EXISTS "activities";
Comment thread
themarolt marked this conversation as resolved.
Comment thread
themarolt marked this conversation as resolved.
33 changes: 7 additions & 26 deletions backend/src/database/repositories/memberRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -937,12 +937,12 @@ class MemberRepository {
})

if (data.length > 0 && data[0].memberId !== record.id) {
let memberSegment = (await seq.query(
const memberSegment = (await seq.query(
`
select distinct a."segmentId", a."memberId"
from activities a where a."memberId" = :memberId
limit 1
`,
select distinct ms."segmentId", ms."memberId"
from "memberSegments" ms where ms."memberId" = :memberId
limit 1
`,
{
replacements: {
memberId: data[0].memberId,
Expand All @@ -952,27 +952,8 @@ class MemberRepository {
},
)) as any[]

// if there's no activity for the member, check memberSegments table
if (memberSegment.length === 0) {
memberSegment = (await seq.query(
Comment thread
cursor[bot] marked this conversation as resolved.
`
select distinct ms."segmentId", ms."memberId"
from "memberSegments" ms where ms."memberId" = :memberId
limit 1
`,
{
replacements: {
memberId: data[0].memberId,
},
type: QueryTypes.SELECT,
transaction,
},
)) as any[]

// still not found, throw an error
if (!memberSegment) {
throw new Error('Member with same identity already exists!')
}
if (!memberSegment) {
throw new Error('Member with same identity already exists!')
}
Comment thread
themarolt marked this conversation as resolved.

const segmentInfo = (await seq.query(
Expand Down
Loading
Loading