Skip to content

Commit

Permalink
Fix org attributes upsert for org merging
Browse files Browse the repository at this point in the history
  • Loading branch information
sausage-todd committed Jul 2, 2024
1 parent 960e9dc commit 8297cdf
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ CREATE TABLE "orgAttributes" (
-- make sure there is only one default attribute
CREATE UNIQUE INDEX "orgAttributes_organizationId_name_default" ON "orgAttributes" ("organizationId", "name", "default") WHERE "default";

-- make sure there are no duplicate values for the same attribute and the same source
-- MD5 is needed because descriptions and *ByMonth fields can be too long for an index
CREATE UNIQUE INDEX "orgAttributes_organizationId_name_source_value" ON "orgAttributes" ("organizationId", "name", "source", MD5("value"));

CREATE OR REPLACE FUNCTION add_org_attribute(
_org_id UUID,
_type TEXT,
Expand Down
1 change: 1 addition & 0 deletions services/apps/search_sync_api/src/routes/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ router.post(
await organizationSyncService.syncOrganizations(organizationIds)
res.sendStatus(200)
} catch (error) {
req.log.error(error, 'Error while syncing organizations')
res.status(500).send(error.message)
}
}),
Expand Down
2 changes: 1 addition & 1 deletion services/libs/data-access-layer/src/org_merge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function findOrgNoMergeIds(
`
SELECT
"noMergeId"
JOIN "organizationNoMerge"
FROM "organizationNoMerge"
WHERE "organizationId" = $(organizationId)
`,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function fetchOrgAggregates(
SELECT
*
FROM "organizationSegmentsAgg"
WHERE "organizationId" = ($(organizationIds)
WHERE "organizationId" = $(organizationId)
LIMIT 1
`,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function buildFullOrgForMergeSuggestions(
...organization,
ticker: attributes.find((a) => a.name === 'ticker' && a.default)?.value,
identities,
activityCount: aggregates.activityCount,
activityCount: aggregates?.activityCount || 0,
noMergeIds,
website: identities.find((i) => i.type === OrganizationIdentityType.PRIMARY_DOMAIN)?.value,
}
Expand Down

0 comments on commit 8297cdf

Please sign in to comment.