mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-28 15:27:03 +02:00
fix(API): Insights - round failure rate to 3 decimals (#14325)
This commit is contained in:
parent
08450b20af
commit
cf37ee3ced
|
|
@ -58,7 +58,7 @@ describe('InsightsController', () => {
|
|||
expect(response).toEqual({
|
||||
total: { deviation: null, unit: 'count', value: 30 },
|
||||
failed: { deviation: null, unit: 'count', value: 10 },
|
||||
failureRate: { deviation: null, unit: 'ratio', value: 0.33 },
|
||||
failureRate: { deviation: null, unit: 'ratio', value: 0.333 },
|
||||
averageRunTime: { deviation: null, unit: 'time', value: 10 },
|
||||
timeSaved: { deviation: null, unit: 'time', value: 10 },
|
||||
});
|
||||
|
|
@ -84,7 +84,7 @@ describe('InsightsController', () => {
|
|||
expect(response).toEqual({
|
||||
total: { deviation: 10, unit: 'count', value: 30 },
|
||||
failed: { deviation: 6, unit: 'count', value: 10 },
|
||||
failureRate: { deviation: 0.33 - 0.2, unit: 'ratio', value: 0.33 },
|
||||
failureRate: { deviation: 0.333 - 0.2, unit: 'ratio', value: 0.333 },
|
||||
averageRunTime: { deviation: 300 / 30 - 40 / 20, unit: 'time', value: 10 },
|
||||
timeSaved: { deviation: 5, unit: 'time', value: 10 },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -754,7 +754,7 @@ describe('getInsightsSummary', () => {
|
|||
});
|
||||
await createCompactedInsightsEvent(workflow, {
|
||||
type: 'failure',
|
||||
value: 2,
|
||||
value: 1,
|
||||
periodUnit: 'day',
|
||||
periodStart: DateTime.utc(),
|
||||
});
|
||||
|
|
@ -778,10 +778,10 @@ describe('getInsightsSummary', () => {
|
|||
// ASSERT
|
||||
expect(summary).toEqual({
|
||||
averageRunTime: { deviation: -123, unit: 'time', value: 0 },
|
||||
failed: { deviation: 2, unit: 'count', value: 2 },
|
||||
failureRate: { deviation: 0.5, unit: 'ratio', value: 0.5 },
|
||||
failed: { deviation: 1, unit: 'count', value: 1 },
|
||||
failureRate: { deviation: 0.333, unit: 'ratio', value: 0.333 },
|
||||
timeSaved: { deviation: 0, unit: 'time', value: 0 },
|
||||
total: { deviation: 3, unit: 'count', value: 4 },
|
||||
total: { deviation: 2, unit: 'count', value: 3 },
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -250,9 +250,9 @@ export class InsightsService {
|
|||
const previousTotal = previousSuccesses + previousFailures;
|
||||
|
||||
const currentFailureRate =
|
||||
currentTotal > 0 ? Math.round((currentFailures / currentTotal) * 100) / 100 : 0;
|
||||
currentTotal > 0 ? Math.round((currentFailures / currentTotal) * 1000) / 1000 : 0;
|
||||
const previousFailureRate =
|
||||
previousTotal > 0 ? Math.round((previousFailures / previousTotal) * 100) / 100 : 0;
|
||||
previousTotal > 0 ? Math.round((previousFailures / previousTotal) * 1000) / 1000 : 0;
|
||||
|
||||
const currentTotalRuntime = getValueByType('current', 'runtime_ms') ?? 0;
|
||||
const previousTotalRuntime = getValueByType('previous', 'runtime_ms') ?? 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user