mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(core): Set up ExecutionMetadata service (no-changelog) (#7103)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -62,11 +62,11 @@ import { findSubworkflowStart, isWorkflowIdValid } from '@/utils';
|
||||
import { PermissionChecker } from './UserManagement/PermissionChecker';
|
||||
import { WorkflowsService } from './workflows/workflows.services';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import type { ExecutionMetadata } from '@db/entities/ExecutionMetadata';
|
||||
import { ExecutionRepository } from '@db/repositories';
|
||||
import { EventsService } from '@/services/events.service';
|
||||
import { SecretsHelper } from './SecretsHelpers';
|
||||
import { OwnershipService } from './services/ownership.service';
|
||||
import { ExecutionMetadataService } from './services/executionMetadata.service';
|
||||
|
||||
const ERROR_TRIGGER_TYPE = config.getEnv('nodes.errorTriggerType');
|
||||
|
||||
@@ -252,22 +252,6 @@ async function pruneExecutionData(this: WorkflowHooks): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveExecutionMetadata(
|
||||
executionId: string,
|
||||
executionMetadata: Record<string, string>,
|
||||
): Promise<ExecutionMetadata[]> {
|
||||
const metadataRows = [];
|
||||
for (const [key, value] of Object.entries(executionMetadata)) {
|
||||
metadataRows.push({
|
||||
execution: { id: executionId },
|
||||
key,
|
||||
value,
|
||||
});
|
||||
}
|
||||
|
||||
return Db.collections.ExecutionMetadata.save(metadataRows);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns hook functions to push data to Editor-UI
|
||||
*
|
||||
@@ -663,7 +647,10 @@ function hookFunctionsSave(parentProcessMode?: string): IWorkflowExecuteHooks {
|
||||
|
||||
try {
|
||||
if (fullRunData.data.resultData.metadata) {
|
||||
await saveExecutionMetadata(this.executionId, fullRunData.data.resultData.metadata);
|
||||
await Container.get(ExecutionMetadataService).save(
|
||||
this.executionId,
|
||||
fullRunData.data.resultData.metadata,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.error(`Failed to save metadata for execution ID ${this.executionId}`, e);
|
||||
@@ -800,7 +787,10 @@ function hookFunctionsSaveWorker(): IWorkflowExecuteHooks {
|
||||
|
||||
try {
|
||||
if (fullRunData.data.resultData.metadata) {
|
||||
await saveExecutionMetadata(this.executionId, fullRunData.data.resultData.metadata);
|
||||
await Container.get(ExecutionMetadataService).save(
|
||||
this.executionId,
|
||||
fullRunData.data.resultData.metadata,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.error(`Failed to save metadata for execution ID ${this.executionId}`, e);
|
||||
|
||||
Reference in New Issue
Block a user