Skip to content

Commit

Permalink
Use ilp for activity conversation mapping (#2639)
Browse files Browse the repository at this point in the history
  • Loading branch information
themarolt authored Oct 10, 2024
1 parent ffe865a commit 5621165
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 214 deletions.
22 changes: 1 addition & 21 deletions backend/src/database/repositories/memberRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1325,10 +1325,6 @@ class MemberRepository {
options: IRepositoryOptions,
segmentId?: string,
): Promise<ActivityAggregates> {
const transaction = SequelizeRepository.getTransaction(options)
const seq = SequelizeRepository.getSequelize(options)
const currentTenant = SequelizeRepository.getCurrentTenant(options)

if (segmentId) {
// we load data for a specific segment (can be leaf, parent or grand parent id)
const member = (
Expand All @@ -1353,22 +1349,7 @@ class MemberRepository {
}
}

const segmentIds = (
await seq.query(
`
select id from segments where "tenantId" = :tenantId and "parentSlug" is not null and "grandparentSlug" is not null
`,
{
replacements: {
tenantId: currentTenant.id,
},
type: QueryTypes.SELECT,
transaction,
},
)
).map((r: any) => r.id)

const results = await getMemberAggregates(options.qdb, memberId, segmentIds)
const results = await getMemberAggregates(options.qdb, memberId)

if (results.length > 0) {
return results[0]
Expand Down Expand Up @@ -1496,7 +1477,6 @@ class MemberRepository {
segments: true,
onlySubProjects: true,
maintainers: true,
attributes: false,
...include,
},
},
Expand Down
7 changes: 2 additions & 5 deletions services/apps/activities_worker/src/activities.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import {
createConversations,
linkActivitiesToConversations,
} from './activities/createConversations'
import { createConversations } from './activities/createConversations'

export { createConversations, linkActivitiesToConversations }
export { createConversations }
Loading

0 comments on commit 5621165

Please sign in to comment.