From 7508b01e6fa503f4094a962f3412255f256045ae Mon Sep 17 00:00:00 2001
From: Khalid Adil <khalidadil29@gmail.com>
Date: Tue, 3 Dec 2024 04:07:57 -0600
Subject: [PATCH] Evaluate all criteria

---
 .../condition/HistoricalTelemetryProvider.js        | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

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