Skip to content

Commit

Permalink
Allow passing a limit parameter to readings endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Jan 13, 2025
1 parent 19567c4 commit 82cba47
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/models/kairos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -26,6 +28,7 @@ def self.query params

component = device.find_component_by_sensor_id(sensor_id)


unless component
return {
device_id: params[:id],
Expand All @@ -44,6 +47,7 @@ def self.query params
metrics = [{
tags: { device_id: params[:id] },
name: sensor_key,
limit: limit,
aggregators: [
{
name: function,
Expand All @@ -54,7 +58,7 @@ def self.query params
}
}
]
}]
}.compact]

data = { metrics: metrics, cache_time: 0 }

Expand Down
1 change: 0 additions & 1 deletion spec/requests/v0/password_resets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 82cba47

Please sign in to comment.