diff --git a/app/models/kairos.rb b/app/models/kairos.rb index b755b231..e7d41740 100644 --- a/app/models/kairos.rb +++ b/app/models/kairos.rb @@ -15,6 +15,8 @@ def self.query params rollup_value = params[:rollup].to_i rollup_unit = Kairos.get_timespan( params[:rollup].gsub(rollup_value.to_s,'') ) + limit = params[:limit]&.to_i + device = Device.find(params[:id]) if sensor_key = params[:sensor_key] @@ -26,6 +28,7 @@ def self.query params component = device.find_component_by_sensor_id(sensor_id) + unless component return { device_id: params[:id], @@ -44,6 +47,7 @@ def self.query params metrics = [{ tags: { device_id: params[:id] }, name: sensor_key, + limit: limit, aggregators: [ { name: function, @@ -54,7 +58,7 @@ def self.query params } } ] - }] + }.compact] data = { metrics: metrics, cache_time: 0 } diff --git a/spec/requests/v0/password_resets_spec.rb b/spec/requests/v0/password_resets_spec.rb index 13c1b440..1cfd239c 100644 --- a/spec/requests/v0/password_resets_spec.rb +++ b/spec/requests/v0/password_resets_spec.rb @@ -117,7 +117,6 @@ it "can reset password with valid token" do expect(user.authenticate('newpass')).to be_falsey j = api_put "password_resets/#{user.password_reset_token}", { password: 'newpass' } - p response expect(j["username"]).to eq(user.username) expect(response.status).to eq(200)