Skip to content

Commit

Permalink
return from kairos query early if component doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Oct 27, 2023
1 parent af9a720 commit 2a4fb7f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/models/kairos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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] },
Expand Down

0 comments on commit 2a4fb7f

Please sign in to comment.