Skip to content

Commit

Permalink
Refactor metric naming and mapping in scenario trends
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy committed Jul 1, 2024
1 parent 7c2f3fd commit 5cc4ac2
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/app/scenario/scenario-trends/scenario-trends.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ScenarioTrendsComponent implements OnInit {
constructor(private scenarioService: ScenarioService, private router: Router,
) {
this.chartDataMapping = new Map([
["percentil", { name: Metrics.ResponseTimeP90, onLoad: true, color: "rgb(17,122,139, 0.8)", tooltip: { valueSuffix: " ms" } }],
["percentile90", { name: Metrics.ResponseTimeP90, onLoad: true, color: "rgb(17,122,139, 0.8)", tooltip: { valueSuffix: " ms" } }],
["avgResponseTime", { name: Metrics.ResponseTimeAvg, onLoad: false, tooltip: { valueSuffix: " ms" } }],
["avgLatency", { name: Metrics.LatencyAvg, onLoad: false, tooltip: { valueSuffix: " ms" } }],
["avgConnect", { name: Metrics.ConnectAvg, onLoad: false, tooltip: { valueSuffix: " ms" } }],
Expand All @@ -53,7 +53,7 @@ export class ScenarioTrendsComponent implements OnInit {
["network", { name: Metrics.Network, yAxis: 4, onLoad: false, transform: this.networkTransform, tooltip: { valueSuffix: " mbps" } }],
]);
}

ngOnInit() {
this.scenarioService.trends$.subscribe((_: {
aggregatedTrends: ScenarioTrendsData[],
Expand All @@ -65,19 +65,25 @@ export class ScenarioTrendsComponent implements OnInit {
return;
}
this.userSettings = _.userSettings;
this.generateAggregateChartLines(_.aggregatedTrends);
this.generateAggregatedChartLines(_.aggregatedTrends);
this.generateLabelChartLines(_.labelTrends);
this.generateDegradationCurve(_.responseTimeDegradationCurve);
});
}

generateAggregateChartLines(data: ScenarioTrendsData[]) {
generateAggregatedChartLines(data: ScenarioTrendsData[]) {
if (!Array.isArray(data)) {
return;
}
const dates = data.map(_ => moment(_.overview.startDate).format("DD. MM. YYYY HH:mm:ss"));
const series = [];
const seriesData = data.reduce((acc, current) => {
const seriesData = data.map((scenarioTrends) => {
// legacy property `percentil` mapped to a new property
if (scenarioTrends.overview["percentil"]) {
scenarioTrends.overview["percentile90"] = scenarioTrends.overview["percentil"]
}
return scenarioTrends
}).reduce((acc, current) => {
for (const key of Object.keys(current.overview)) {

if (!["startDate", "endDate", "duration"].includes(key)) {
Expand Down

0 comments on commit 5cc4ac2

Please sign in to comment.