Evaluate all criteria

This commit is contained in:
Khalid Adil 2024-12-03 04:07:57 -06:00
parent d0768032c4
commit 7508b01e6f

View File

@ -1,3 +1,5 @@
import { evaluateResults } from './utils/evaluator.js';
export default class HistoricalTelemetryProvider { export default class HistoricalTelemetryProvider {
#telemetryOptions; #telemetryOptions;
#telemetryObjects = {}; #telemetryObjects = {};
@ -70,12 +72,17 @@ export default class HistoricalTelemetryProvider {
for (let conditionIndex = 0; conditionIndex < this.#conditions.length; conditionIndex++) { for (let conditionIndex = 0; conditionIndex < this.#conditions.length; conditionIndex++) {
const condition = this.#conditions[conditionIndex]; const condition = this.#conditions[conditionIndex];
const { id } = condition; const { id } = condition;
const conditionCriteria = condition.criteria?.[0]; const conditionCriteria = condition?.criteria.length > 0;
let result = false; let result = false;
let defaultHit = false; let defaultHit = false;
if (conditionCriteria) { if (conditionCriteria) {
const inputTelemetry = this.#getInputTelemetry(conditionCriteria, dataFrame, timestamp); result = evaluateResults(
result = conditionCriteria.computeResult({ id, ...inputTelemetry }); condition.criteria.map((criterion) => {
const inputTelemetry = this.#getInputTelemetry(criterion, dataFrame, timestamp);
return criterion.computeResult({ id, ...inputTelemetry });
}),
condition?.trigger
);
} else { } else {
// default criteria is 'all' // default criteria is 'all'
defaultHit = true; defaultHit = true;