MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / humanizeThresholdRule

Function humanizeThresholdRule

tests/loadtest/tools/dashboard/app.js:1243–1268  ·  view source on GitHub ↗
(rule, metricName)

Source from the content-addressed store, hash-verified

1241}
1242
1243function humanizeThresholdRule(rule, metricName) {
1244 if (!rule) {
1245 return "";
1246 }
1247
1248 let match = rule.match(/^p\((\d+)\)\s*<\s*([\d.]+)$/);
1249 if (match) {
1250 const [, percentileValue, thresholdValue] = match;
1251 return `P${percentileValue} under ${formatThresholdValue(metricName, Number(thresholdValue))}`;
1252 }
1253
1254 match = rule.match(/^(avg|max|min|med|rate)\s*<\s*([\d.]+)$/);
1255 if (match) {
1256 const [, stat, thresholdValue] = match;
1257 const readableStat = {
1258 avg: "Average",
1259 max: "Max",
1260 min: "Min",
1261 med: "Median",
1262 rate: "Rate",
1263 }[stat] || stat;
1264 return `${readableStat} under ${formatThresholdValue(metricName, Number(thresholdValue))}`;
1265 }
1266
1267 return rule.replaceAll("<", " under ").replaceAll(">", " over ");
1268}
1269
1270function formatThresholdValue(metricName, value) {
1271 if (!Number.isFinite(value)) {

Callers 1

humanizeThresholdFunction · 0.85

Calls 1

formatThresholdValueFunction · 0.85

Tested by

no test coverage detected