Skip to content

Commit

Permalink
fix(api-service): translation groups causing long response time in v2…
Browse files Browse the repository at this point in the history
… create/update workflow
  • Loading branch information
LetItRock committed Jan 7, 2025
1 parent d4439d4 commit 8781f78
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
WorkflowInternalResponseDto,
GetWorkflowByIdsUseCase,
} from '../workflow';
import { Instrument, InstrumentUsecase } from '../../instrumentation';

/**
* @deprecated - use `UpsertWorkflow` instead
Expand All @@ -80,6 +81,7 @@ export class CreateWorkflow {
private getWorkflowByIdsUseCase: GetWorkflowByIdsUseCase,
) {}

@InstrumentUsecase()
async execute(
usecaseCommand: CreateWorkflowCommand,
): Promise<WorkflowInternalResponseDto> {
Expand Down Expand Up @@ -114,8 +116,9 @@ export class CreateWorkflow {

try {
if (
process.env.NOVU_ENTERPRISE === 'true' ||
process.env.CI_EE_TEST === 'true'
(process.env.NOVU_ENTERPRISE === 'true' ||
process.env.CI_EE_TEST === 'true') &&
storedWorkflow.origin === WorkflowOriginEnum.NOVU_CLOUD_V1
) {
if (!require('@novu/ee-shared-services')?.TranslationsService) {
throw new PlatformException('Translation module is not loaded');
Expand Down Expand Up @@ -199,6 +202,7 @@ export class CreateWorkflow {
}
}

@Instrument()
private async createNotificationTrigger(
command: CreateWorkflowCommand,
triggerIdentifier: string,
Expand Down Expand Up @@ -316,6 +320,7 @@ export class CreateWorkflow {
}
}

@Instrument()
private async storeWorkflow(
command: CreateWorkflowCommand,
templateSteps: INotificationTemplateStep[],
Expand Down Expand Up @@ -412,6 +417,7 @@ export class CreateWorkflow {
);
}

@Instrument()
private async storeTemplateSteps(
command: CreateWorkflowCommand,
parentChangeId: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
ControlValuesLevelEnum,
isBridgeWorkflow,
PreferencesTypeEnum,
WorkflowOriginEnum,
} from '@novu/shared';

import {
Expand Down Expand Up @@ -61,6 +62,7 @@ import {
UpdateMessageTemplate,
UpdateMessageTemplateCommand,
} from '../../message-template';
import { Instrument, InstrumentUsecase } from '../../../instrumentation';

/**
* @deprecated - use `UpsertWorkflow` instead
Expand Down Expand Up @@ -92,6 +94,7 @@ export class UpdateWorkflow {
private controlValuesRepository: ControlValuesRepository,
) {}

@InstrumentUsecase()
async execute(
command: UpdateWorkflowCommand,
): Promise<WorkflowInternalResponseDto> {
Expand Down Expand Up @@ -370,8 +373,10 @@ export class UpdateWorkflow {

try {
if (
process.env.NOVU_ENTERPRISE === 'true' ||
process.env.CI_EE_TEST === 'true'
(process.env.NOVU_ENTERPRISE === 'true' ||
process.env.CI_EE_TEST === 'true') &&
notificationTemplateWithStepTemplate.origin ===
WorkflowOriginEnum.NOVU_CLOUD_V1
) {
if (!require('@novu/ee-shared-services')?.TranslationsService) {
throw new PlatformException('Translation module is not loaded');
Expand Down Expand Up @@ -420,6 +425,7 @@ export class UpdateWorkflow {
}
}

@Instrument()
private async updateMessageTemplates(
steps: NotificationStep[],
command: UpdateWorkflowCommand,
Expand Down Expand Up @@ -518,6 +524,7 @@ export class UpdateWorkflow {
return templateMessages;
}

@Instrument()
private updateTriggers(
updatePayload: Partial<WorkflowInternalResponseDto>,
steps: NotificationStep[],
Expand Down Expand Up @@ -735,6 +742,7 @@ export class UpdateWorkflow {
return variantsList;
}

@Instrument()
private async deleteRemovedSteps(
existingSteps: NotificationStepEntity[] | StepVariantEntity[] | undefined,
command: UpdateWorkflowCommand,
Expand Down

0 comments on commit 8781f78

Please sign in to comment.