UNPKG

@nitin15j/plugin-dora-frontend

Version:
45 lines (42 loc) 1.77 kB
import { MetricType, Performance } from '../types/metrics.esm.js'; import { PERFORMANCE_THRESHOLDS } from '../constants/thresholds.esm.js'; const calculateTrendChange = (current, previous) => { if (previous === 0) return 0; const result = (current - previous) / previous * 100; return Math.round(result * 10) / 10; }; const calculateTrendChangeSimple = (current, previous) => { if (previous === 0) return 0; return (current - previous) / previous * 100; }; const getMetricPerformance = (metricType, value) => { const thresholds = PERFORMANCE_THRESHOLDS[metricType]; if (value >= thresholds[Performance.Elite]) return Performance.Elite; if (value >= thresholds[Performance.High]) return Performance.High; if (value >= thresholds[Performance.Medium]) return Performance.Medium; return Performance.Low; }; const determineTrend = (current, previous, metricType) => { const change = calculateTrendChangeSimple(current, previous); if (metricType === MetricType.LeadTime || metricType === MetricType.Mttr) { return change <= -5 ? "up" : change >= 5 ? "down" : "stable"; } if (metricType === MetricType.Frequency) { return change >= 5 ? "up" : change <= -5 ? "down" : "stable"; } if (metricType === MetricType.FailureRate) { return change <= -5 ? "up" : change >= 5 ? "down" : "stable"; } return "stable"; }; const determineOverallTrend = (frequencyTrend, leadTimeTrend, failureRateTrend) => { if (failureRateTrend === "down" || leadTimeTrend === "down") { return "down"; } if (frequencyTrend === "up") { return "up"; } return "stable"; }; export { calculateTrendChange, calculateTrendChangeSimple, determineOverallTrend, determineTrend, getMetricPerformance }; //# sourceMappingURL=calculations.esm.js.map