Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export default class MemberEnrichmentService extends LoggerBase {

async bulkEnrich(memberIds: string[], notifyFrontend: boolean = true) {
const redis = await getRedisClient(REDIS_CONFIG, true)
const searchSyncEmitter = await getSearchSyncWorkerEmitter()

const apiPubSubEmitter = new RedisPubSubEmitter(
'api-pubsub',
Expand All @@ -158,6 +159,7 @@ export default class MemberEnrichmentService extends LoggerBase {
try {
await this.enrichOne(memberId)
enrichedMembers++
await searchSyncEmitter.triggerMemberSync(this.options.currentTenant.id, memberId)
this.log.info(`Enriched member ${memberId}`)
} catch (err) {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
IOrganization,
IOrganizations,
} from './types/organizationEnrichmentTypes'
import { getSearchSyncWorkerEmitter } from '@/serverless/utils/serviceSQS'

export default class OrganizationEnrichmentService extends LoggerBase {
tenantId: string
Expand Down Expand Up @@ -105,9 +106,23 @@ export default class OrganizationEnrichmentService extends LoggerBase {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
private async update(orgs: IOrganizations): Promise<IOrganizations> {
const searchSyncEmitter = await getSearchSyncWorkerEmitter()

// TODO: Update cache
// await OrganizationCacheRepository.bulkUpdate(cacheOrgs, this.options, true)
return OrganizationRepository.bulkUpdate(orgs, [...this.fields], this.options, true)
const records = await OrganizationRepository.bulkUpdate(
orgs,
[...this.fields],
this.options,
true,
)

for (const org of records) {
// trigger open search sync
await searchSyncEmitter.triggerOrganizationSync(this.options.currentTenant.id, org.id)
}

return records
}

private static sanitize(data: IEnrichableOrganization): IEnrichableOrganization {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@
placeholder=" "
>
<el-option
v-for="option in revenueRangesOptions"
:key="option.id"
:value="option.value"
:label="option.label"
:value="model[fields.revenueRange.name]"
:label="revenueRange.displayValue(model[fields.revenueRange.name])"
/>
</el-select>
</el-form-item>
Expand All @@ -104,7 +102,7 @@
<script setup>
import { defineEmits, defineProps, computed } from 'vue';
import AppSvg from '@/shared/svg/svg.vue';
import { revenueRangesOptions } from '@/modules/organization/config/enrichment/revenueRange';
import revenueRange from '@/modules/organization/config/enrichment/revenueRange';

const emit = defineEmits(['update:modelValue']);
const props = defineProps({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,76 +1,24 @@
import { attributesTypes } from '@/modules/organization/types/Attributes';

export const revenueRangesOptions = [
{
label: '$0-1M',
value: {
min: 0,
max: 1,
},
},
{
label: '$1M-$10M',
value: {
min: 1,
max: 10,
},
},
{
label: '$10M-$25M',
value: {
min: 10,
max: 25,
},
},
{
label: '$25M-$50M',
value: {
min: 25,
max: 50,
},
},
{
label: '$50M-$100M',
value: {
min: 50,
max: 100,
},
},
{
label: '$100M-$250M',
value: {
min: 100,
max: 250,
},
},
{
label: '$250M-$500M',
value: {
min: 250,
max: 500,
},
},
{
label: '$500M-$1B',
value: {
min: 500,
max: 1000,
},
},
{
label: '$1B-$10B',
value: {
min: 1000,
max: 10000,
},
},
{
label: '$10B+',
value: {
min: 10000,
},
},
];
const getValue = (value) => {
if (value === undefined || value === null) {
return '';
}

return `$${value >= 1000 ? value / 1000 : value}${value >= 1000 ? 'B' : 'M'}`;
};

const getMiddle = (min, max) => {
if (min && max) {
return '-';
}

if (min && !max) {
return '+';
}

return '';
};

export default {
name: 'revenueRange',
Expand All @@ -79,10 +27,13 @@ export default {
showInForm: false,
showInAttributes: false,
displayValue: (value) => {
if (!value) {
if (!Object.keys(value || {}).length) {
return '-';
}

return revenueRangesOptions.find((range) => range.value.min === value.min && range.value.max === value.max)?.label || value;
const min = getValue(value.min);
const max = getValue(value.max);

return `${min}${getMiddle(min, max)}${max}`;
},
};