Skip to content

Commit 8777710

Browse files
committed
fix lfxMembership filter in organization query
1 parent 11840a7 commit 8777710

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

backend/src/database/repositories/organizationRepository.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -316,25 +316,6 @@ class OrganizationRepository {
316316
}
317317
}
318318

319-
static findLfxMembershipInFilters(filter: any): any {
320-
if (!filter) return null
321-
322-
if (filter.lfxMembership) {
323-
return filter.lfxMembership
324-
}
325-
326-
if (Array.isArray(filter.and)) {
327-
for (const subFilter of filter.and) {
328-
const result = OrganizationRepository.findLfxMembershipInFilters(subFilter)
329-
if (result) {
330-
return result
331-
}
332-
}
333-
}
334-
335-
return null
336-
}
337-
338319
static convertOrgAttributesForDisplay(attributes: IDbOrgAttribute[]) {
339320
return attributes.reduce((acc, a) => {
340321
if (!acc[a.name]) {
@@ -1615,7 +1596,7 @@ class OrganizationRepository {
16151596
const withAggregates = include.aggregates
16161597

16171598
// look for lfxMembership filter
1618-
const lfxMembershipFilter = OrganizationRepository.findLfxMembershipInFilters(filter)
1599+
const lfxMembershipFilter = filter.and?.find(f => f.lfxMembership)?.lfxMembership
16191600
let lfxMembershipFilterWhereClause = ''
16201601

16211602
if (lfxMembershipFilter) {
@@ -1627,8 +1608,9 @@ class OrganizationRepository {
16271608
}
16281609

16291610
// remove lfxMembership filter from obj since filterParser doesn't support it
1630-
filter.and = filter.and.filter((f) => !f.and?.some((subF) => subF.lfxMembership))
1611+
filter.and = filter.and.filter(f => !f.lfxMembership)
16311612
}
1613+
16321614
if (segmentId) {
16331615
const segment = (await findSegmentById(optionsQx(options), segmentId)) as any
16341616

0 commit comments

Comments
 (0)