feat: add independent spread metric filters

This commit is contained in:
wxs
2026-07-10 17:48:02 +08:00
parent b48e244a99
commit 9326d676b7
5 changed files with 767 additions and 356 deletions
+1 -17
View File
@@ -1,8 +1,7 @@
import type {
SpreadInfoConfig,
SpreadInfoMetrics,
SpreadMetricFilterRule,
SpreadMetricThresholds
SpreadMetricFilterRule
} from "./types";
interface FetchResponseLike {
@@ -205,21 +204,6 @@ export function mapSpreadInfoResponse(
};
}
export function matchesSpreadThresholds(
metrics: MappedSpreadInfoResponse,
thresholds: SpreadMetricThresholds
): boolean {
return Object.entries(thresholds).every(([key, threshold]) => {
if (typeof threshold !== "number" || !Number.isFinite(threshold)) {
return true;
}
const metricValue = metrics[key as keyof SpreadMetricThresholds];
const numericValue = readDisplayNumber(metricValue);
return numericValue !== null && numericValue >= threshold;
});
}
export function normalizeSpreadInfoConfig(
config: SpreadInfoConfig
): SpreadInfoConfig {