Skip to content

Commit a53921d

Browse files
committed
refactor(plugin-awesome, plugin-dashboard, web-commons): introduce DEFAULT_CHART_HISTORY_LIMIT and update trend chart options
1 parent a00fc7a commit a53921d

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

packages/plugin-awesome/src/charts.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { HistoryDataPoint, SeverityLevel, Statistic, TestResult, TestStatus } from "@allurereport/core-api";
22
import type { AllureStore, PluginContext } from "@allurereport/plugin-api";
3-
import { getPieChartDataDashboard, getSeverityTrendData, getStatusTrendData } from "@allurereport/web-commons";
3+
import { getPieChartDataDashboard, getSeverityTrendData, getStatusTrendData, DEFAULT_CHART_HISTORY_LIMIT } from "@allurereport/web-commons";
44
import { randomUUID } from "crypto";
55
import type { PieArcDatum } from "d3-shape";
66
import { arc, pie } from "d3-shape";
@@ -416,13 +416,14 @@ export const generateTrendChart = (
416416
},
417417
context: PluginContext,
418418
): TrendChartData | undefined => {
419-
const { dataType } = options;
419+
const newOptions = { limit: DEFAULT_CHART_HISTORY_LIMIT, ...options };
420+
const { dataType } = newOptions;
420421
const { statistic, historyDataPoints, testResults } = stores;
421422

422423
if (dataType === ChartData.Status) {
423-
return getStatusTrendData(statistic, context.reportName, historyDataPoints, options);
424+
return getStatusTrendData(statistic, context.reportName, historyDataPoints, newOptions);
424425
} else if (dataType === ChartData.Severity) {
425-
return getSeverityTrendData(testResults, context.reportName, historyDataPoints, options);
426+
return getSeverityTrendData(testResults, context.reportName, historyDataPoints, newOptions);
426427
}
427428
};
428429

packages/plugin-dashboard/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Trend charts allow you to track metrics over time. Available configurations:
6666
type: "trend",
6767
dataType: "status",
6868
mode: "percent", // optional, default: "raw"
69-
limit: 10, // optional: limit number of builds
69+
limit: 10, // optional: limit number of builds, default: 10
7070
title: "Custom Status Trend", // optional
7171
metadata: { // optional
7272
executionIdAccessor: (executionOrder) => `build-${executionOrder}`,

packages/plugin-dashboard/src/generators.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
createReportDataScript,
77
createScriptTag,
88
createStylesLinkTag,
9+
DEFAULT_CHART_HISTORY_LIMIT,
910
} from "@allurereport/web-commons";
1011
import type { DashboardReportOptions } from "@allurereport/web-dashboard";
1112
import { randomUUID } from "crypto";
@@ -87,13 +88,14 @@ const generateTrendChart = (
8788
},
8889
context: PluginContext,
8990
): TrendChartData | undefined => {
90-
const { dataType } = options;
91+
const newOptions = { limit: DEFAULT_CHART_HISTORY_LIMIT, ...options };
92+
const { dataType } = newOptions;
9193
const { statistic, historyDataPoints, testResults } = stores;
9294

9395
if (dataType === ChartData.Status) {
94-
return getStatusTrendData(statistic, context.reportName, historyDataPoints, options);
96+
return getStatusTrendData(statistic, context.reportName, historyDataPoints, newOptions);
9597
} else if (dataType === ChartData.Severity) {
96-
return getSeverityTrendData(testResults, context.reportName, historyDataPoints, options);
98+
return getSeverityTrendData(testResults, context.reportName, historyDataPoints, newOptions);
9799
}
98100
};
99101

packages/web-commons/src/charts.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { arc, pie } from "d3-shape";
44

55
export type BasePieSlice = Pick<PieSlice, "status" | "count">;
66

7+
export const DEFAULT_CHART_HISTORY_LIMIT = 10;
8+
79
export const d3Arc = arc<PieArcDatum<BasePieSlice>>().innerRadius(40).outerRadius(50).cornerRadius(2).padAngle(0.03);
810

911
export const d3Pie = pie<BasePieSlice>()

0 commit comments

Comments
 (0)