UNPKG

n8n

Version:

n8n Workflow Automation Tool

80 lines (79 loc) 3.12 kB
import type { InsightsSummary } from '@n8n/api-types'; import { Logger } from 'n8n-core'; import type { ExecutionLifecycleHooks } from 'n8n-core'; import { type IRun } from 'n8n-workflow'; import { SharedWorkflowRepository } from '../../databases/repositories/shared-workflow.repository'; import { InsightsRaw } from '../../modules/insights/database/entities/insights-raw'; import type { PeriodUnit } from './database/entities/insights-shared'; import { InsightsByPeriodRepository } from './database/repositories/insights-by-period.repository'; import { InsightsRawRepository } from './database/repositories/insights-raw.repository'; type BufferedInsight = Pick<InsightsRaw, 'type' | 'value' | 'timestamp'> & { workflowId: string; workflowName: string; }; export declare class InsightsService { private readonly sharedWorkflowRepository; private readonly insightsByPeriodRepository; private readonly insightsRawRepository; private readonly logger; private readonly cachedMetadata; private compactInsightsTimer; private bufferedInsights; private flushInsightsRawBufferTimer; private isAsynchronouslySavingInsights; private flushesInProgress; constructor(sharedWorkflowRepository: SharedWorkflowRepository, insightsByPeriodRepository: InsightsByPeriodRepository, insightsRawRepository: InsightsRawRepository, logger: Logger); startBackgroundProcess(): void; stopBackgroundProcess(): void; private startCompactionScheduler; private stopCompactionScheduler; private startFlushingScheduler; private stopFlushingScheduler; shutdown(): Promise<void>; workflowExecuteAfterHandler(ctx: ExecutionLifecycleHooks, fullRunData: IRun): Promise<void>; saveInsightsMetadataAndRaw(insightsRawToInsertBuffer: Set<BufferedInsight>): Promise<void>; flushEvents(): Promise<void>; compactInsights(): Promise<void>; compactRawToHour(): Promise<number>; compactHourToDay(): Promise<number>; compactDayToWeek(): Promise<number>; getInsightsSummary({ periodLengthInDays, }: { periodLengthInDays: number; }): Promise<InsightsSummary>; getInsightsByWorkflow({ maxAgeInDays, skip, take, sortBy, }: { maxAgeInDays: number; skip?: number; take?: number; sortBy?: string; }): Promise<{ count: number; data: { workflowId: string; projectId: string; workflowName: string; failed: number; projectName: string; succeeded: number; total: number; failureRate: number; runTime: number; averageRunTime: number; timeSaved: number; }[]; }>; getInsightsByTime({ maxAgeInDays, periodUnit, }: { maxAgeInDays: number; periodUnit: PeriodUnit; }): Promise<{ date: string; values: { total: number; succeeded: number; failed: number; failureRate: number; averageRunTime: number; timeSaved: number; }; }[]>; } export {};