mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
feat(API): Return null deviation on insights summary if previous period has no data (#14193)
This commit is contained in:
committed by
GitHub
parent
41b1797a25
commit
ffc0a596e0
@@ -44,6 +44,15 @@ describe('InsightsSummary', () => {
|
||||
{ id: 'averageRunTime', value: 2.5, deviation: 0.5, unit: 's' },
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
{ id: 'total', value: 525, deviation: null, unit: '' },
|
||||
{ id: 'failed', value: 14, deviation: null, unit: '' },
|
||||
{ id: 'failureRate', value: 1.9, deviation: null, unit: '%' },
|
||||
{ id: 'timeSaved', value: 55.55555555555556, deviation: null, unit: 'h' },
|
||||
{ id: 'averageRunTime', value: 2.5, deviation: null, unit: 's' },
|
||||
],
|
||||
],
|
||||
])('should render the summary correctly', (summary) => {
|
||||
const { html } = renderComponent({
|
||||
props: {
|
||||
|
||||
@@ -76,7 +76,7 @@ const getImpactStyle = (id: keyof InsightsSummary, value: number) => {
|
||||
<em
|
||||
>{{ smartDecimal(value) }} <i>{{ unit }}</i></em
|
||||
>
|
||||
<small :class="getImpactStyle(id, deviation)">
|
||||
<small v-if="deviation !== null" :class="getImpactStyle(id, deviation)">
|
||||
<N8nIcon
|
||||
:class="[$style.icon, getImpactStyle(id, deviation)]"
|
||||
:icon="deviation === 0 ? 'caret-right' : deviation > 0 ? 'caret-up' : 'caret-down'"
|
||||
|
||||
@@ -73,3 +73,26 @@ exports[`InsightsSummary > should render the summary correctly 4`] = `
|
||||
</ul>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
exports[`InsightsSummary > should render the summary correctly 5`] = `
|
||||
"<div class="insights">
|
||||
<h3 class="n8n-heading text-light size-small bold mb-xs mb-xs">Production executions for the last 7 days</h3>
|
||||
<ul data-test-id="insights-summary-tabs">
|
||||
<li data-test-id="insights-summary-tab-total">
|
||||
<p><strong>Total</strong><span><em>525 <i></i></em><!--v-if--></span></p>
|
||||
</li>
|
||||
<li data-test-id="insights-summary-tab-failed">
|
||||
<p><strong>Failed</strong><span><em>14 <i></i></em><!--v-if--></span></p>
|
||||
</li>
|
||||
<li data-test-id="insights-summary-tab-failureRate">
|
||||
<p><strong>Failure rate</strong><span><em>1.9 <i>%</i></em><!--v-if--></span></p>
|
||||
</li>
|
||||
<li data-test-id="insights-summary-tab-timeSaved">
|
||||
<p><strong>Time saved</strong><span><em>55.56 <i>h</i></em><!--v-if--></span></p>
|
||||
</li>
|
||||
<li data-test-id="insights-summary-tab-averageRunTime">
|
||||
<p><strong>Avg. run time</strong><span><em>2.5 <i>s</i></em><!--v-if--></span></p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>"
|
||||
`;
|
||||
|
||||
@@ -7,7 +7,7 @@ export type InsightsSummaryDisplay = Array<
|
||||
[K in keyof InsightsDisplayUnits]: {
|
||||
id: K;
|
||||
value: number;
|
||||
deviation: number;
|
||||
deviation: number | null;
|
||||
unit: InsightsDisplayUnits[K];
|
||||
};
|
||||
}[keyof InsightsDisplayUnits]
|
||||
|
||||
@@ -16,7 +16,9 @@ export const transformInsightsSummary = (data: InsightsSummary | null): Insights
|
||||
? INSIGHTS_SUMMARY_ORDER.map((key) => ({
|
||||
id: key,
|
||||
value: transformInsightsValues[key]?.(data[key].value) ?? data[key].value,
|
||||
deviation: transformInsightsValues[key]?.(data[key].deviation) ?? data[key].deviation,
|
||||
deviation: data[key].deviation
|
||||
? (transformInsightsValues[key]?.(data[key].deviation) ?? data[key].deviation)
|
||||
: null,
|
||||
unit: INSIGHTS_UNIT_MAPPING[key],
|
||||
}))
|
||||
: [];
|
||||
|
||||
Reference in New Issue
Block a user