Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspergrom committed Oct 28, 2024
1 parent 14b3e83 commit b355721
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions backend/src/database/repositories/dataQualityRepository.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {
fetchMembersWithConflictingWorkExperiences,
fetchMembersWithMissingInfoOnWorkExperience,
fetchMembersWithMissingPeriodOnWorkExperience,
fetchMembersWithTooManyEmails,
fetchMembersWithTooManyIdentities,
fetchMembersWithTooManyIdentitiesPerPlatform,
fetchMembersWithoutWorkExperience, fetchMembersWithConflictingWorkExperiences,
fetchMembersWithoutWorkExperience,
} from '@crowd/data-access-layer/src/data-quality'

import SequelizeRepository from '@/database/repositories/sequelizeRepository'
Expand Down Expand Up @@ -140,7 +141,6 @@ class DataQualityRepository {
return fetchMembersWithMissingPeriodOnWorkExperience(qx, tenantId, limit, offset, segmentId)
}


/**
* Finds members with conflicting work experience based on specified options.
*
Expand Down
18 changes: 10 additions & 8 deletions services/libs/data-access-layer/src/data-quality/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,17 @@ export async function fetchMembersWithConflictingWorkExperiences(
msa."activityCount",
COUNT(mo1.id) AS "organizationsCount"
FROM "members" m
JOIN "memberOrganizations" mo1 ON m.id = mo1."memberId" AND mo1."deletedAt" IS NULL
INNER JOIN "memberSegmentsAgg" msa ON m.id = msa."memberId" AND msa."segmentId" = '${segmentId}'
JOIN "memberOrganizations" mo2 ON mo1."memberId" = mo2."memberId"
AND mo1."organizationId" = mo2."organizationId"
AND mo1.id != mo2.id
AND mo1."dateStart" <= COALESCE(mo2."dateEnd", 'infinity'::timestamp)
AND COALESCE(mo1."dateEnd", 'infinity'::timestamp) >= mo2."dateStart"
JOIN "memberOrganizations" mo1 ON m.id = mo1."memberId" AND mo1."deletedAt" IS NULL
INNER JOIN "memberSegmentsAgg" msa ON m.id = msa."memberId" AND msa."segmentId" = '${segmentId}'
JOIN "memberOrganizations" mo2 ON mo1."memberId" = mo2."memberId"
AND mo1.id != mo2.id
AND (
(mo1."dateStart" <= COALESCE(mo2."dateEnd", 'infinity'::timestamp)
AND COALESCE(mo1."dateEnd", 'infinity'::timestamp) >= mo2."dateStart") OR
(mo2."dateStart" <= COALESCE(mo1."dateEnd", 'infinity'::timestamp)
AND COALESCE(mo2."dateEnd", 'infinity'::timestamp) >= mo1."dateStart")
)
WHERE m."tenantId" = '${tenantId}'
AND COALESCE((m.attributes -> 'isBot' ->> 'default')::BOOLEAN, FALSE) = FALSE
GROUP BY m.id, msa."activityCount"
ORDER BY msa."activityCount" DESC
LIMIT ${limit} OFFSET ${offset};
Expand Down

0 comments on commit b355721

Please sign in to comment.