Skip to content

Commit 4362817

Browse files
committed
chore: update source and other logic
1 parent 1cbf5f1 commit 4362817

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

services/libs/data-access-layer/src/enrichment/organizationEnrichmentCache/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OrganizationEnrichmentSource } from '@crowd/types'
1+
import { IOrganizationEnrichmentCache, OrganizationEnrichmentSource } from '@crowd/types'
22

33
import { QueryExecutor } from '../../queryExecutor'
44

@@ -7,20 +7,20 @@ export async function insertOrganizationEnrichmentCache<T>(
77
organizationId: string,
88
data: T,
99
source: OrganizationEnrichmentSource,
10-
) {
11-
return qx.result(
10+
): Promise<void> {
11+
await qx.result(
1212
`insert into "organizationEnrichmentCache" ("organizationId", "data", "source", "createdAt", "updatedAt")
1313
values ($(organizationId), $(data), $(source), now(), now())
1414
on conflict ("organizationId", "source") do update set "data" = $(data), "updatedAt" = now()`,
1515
{ organizationId, data, source },
1616
)
1717
}
1818

19-
export async function findOrganizationEnrichmentCache(
19+
export async function findOrganizationEnrichmentCache<T>(
2020
qx: QueryExecutor,
2121
organizationId: string,
2222
source: OrganizationEnrichmentSource,
23-
) {
23+
): Promise<IOrganizationEnrichmentCache<T> | null> {
2424
return qx.selectOneOrNone(
2525
`select * from "organizationEnrichmentCache" where "organizationId" = $(organizationId) and "source" = $(source)`,
2626
{ organizationId, source },
@@ -32,8 +32,8 @@ export async function updateOrganizationEnrichmentCache<T>(
3232
organizationId: string,
3333
data: T,
3434
source: OrganizationEnrichmentSource,
35-
) {
36-
return qx.result(
35+
): Promise<void> {
36+
await qx.result(
3737
`update "organizationEnrichmentCache" set "data" = $(data), "updatedAt" = now() where "organizationId" = $(organizationId) and "source" = $(source)`,
3838
{ organizationId, data, source },
3939
)

services/libs/types/src/enrichment.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MemberEnrichmentSource } from './enums'
1+
import { MemberEnrichmentSource, OrganizationEnrichmentSource } from './enums'
22
import { IMemberIdentity, IMemberReach } from './members'
33
import { IOrganizationIdentity } from './organizations'
44

@@ -55,3 +55,11 @@ export interface IMemberOriginalData {
5555
// memberOrganizations table data
5656
organizations: IMemberOrganizationData[]
5757
}
58+
59+
export interface IOrganizationEnrichmentCache<T> {
60+
createdAt: string
61+
updatedAt: string
62+
organizationId: string
63+
data: T
64+
source: OrganizationEnrichmentSource
65+
}

services/libs/types/src/enums/enrichment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ export enum MemberEnrichmentMaterializedView {
1919
}
2020

2121
export enum OrganizationEnrichmentSource {
22-
CLEARBIT = 'clearbit',
23-
}
22+
INTERNAL_API = 'internal-api',
23+
}

0 commit comments

Comments
 (0)