From 2a4fb7feee99ada427cbb576602168c1c2f8d2d3 Mon Sep 17 00:00:00 2001 From: Tim Cowlishaw Date: Fri, 27 Oct 2023 11:08:56 +0200 Subject: [PATCH] return from kairos query early if component doesn't exist --- app/models/kairos.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/models/kairos.rb b/app/models/kairos.rb index 942df963..b755b231 100644 --- a/app/models/kairos.rb +++ b/app/models/kairos.rb @@ -26,6 +26,20 @@ def self.query params component = device.find_component_by_sensor_id(sensor_id) + unless component + return { + device_id: params[:id], + sensor_key: sensor_key, + sensor_id: sensor_id, + component_id: nil, + rollup: params[:rollup], + function: function, + from: params[:from], + to: params[:to], + sample_size: 0, + readings: [], + } + end metrics = [{ tags: { device_id: params[:id] },