2baf29b3ae
Deliver encrypted health zone, observation API, baseline maturity pipeline, page-data bindings, and H5/WeChat channel integration for health P0. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
937 B
JavaScript
29 lines
937 B
JavaScript
export const BASELINE_MATURITY = Object.freeze({
|
|
COLD: 'cold',
|
|
WEAK: 'weak',
|
|
STABLE: 'stable',
|
|
});
|
|
|
|
export function resolveBaselineMaturity(sampleCount) {
|
|
const n = Number(sampleCount ?? 0);
|
|
if (!Number.isFinite(n) || n < 7) return BASELINE_MATURITY.COLD;
|
|
if (n < 30) return BASELINE_MATURITY.WEAK;
|
|
return BASELINE_MATURITY.STABLE;
|
|
}
|
|
|
|
export function allowedEventSeverities(maturity) {
|
|
if (maturity === BASELINE_MATURITY.STABLE) return ['info', 'watch', 'alert'];
|
|
if (maturity === BASELINE_MATURITY.WEAK) return ['info'];
|
|
return [];
|
|
}
|
|
|
|
export function canEmitHealthEvent(maturity, severity) {
|
|
return allowedEventSeverities(maturity).includes(String(severity ?? ''));
|
|
}
|
|
|
|
export function isValidObservationForBaseline(row = {}) {
|
|
const qualityFlag = row.quality_flag ?? row.qualityFlag ?? 'ok';
|
|
const deletedAt = row.deleted_at ?? row.deletedAt ?? null;
|
|
return qualityFlag !== 'suspect' && deletedAt == null;
|
|
}
|