-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metrics filtering to devices query #1598
base: main
Are you sure you want to change the base?
Conversation
@elinol did you want a code review on this PR? |
@elinol oh yeah, I noticed that this is still in Draft, is this ready for review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need any tests for this?
e02b266
to
5f5b145
Compare
@joshk I don't remember why there's no filters selectors added to the UI, did we wanna wait for the new UI? I could add them before merging this, or after if preferred. |
I think it might be good to add it to the current UI, as the new UI is still a little bit away. |
@@ -221,10 +225,38 @@ defmodule NervesHub.Devices do | |||
else | |||
query | |||
end | |||
|
|||
{_, _} -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this (realized now it could be just a _
..) instead of cases for {:metrics_key, _}
and {:metrics_operator, _}
since they depend on :metrics_value
to execute anything. Any thoughts on that @joshk ?
b9289c0
to
4ac3549
Compare
Implements filtering on metric values.
What we want is to:
get all devices where the latest associated device metric for specified key is matching the provided filter (greater or less than X)
The current query gives the latest device metric where the requirements are met, so if there are at least one metric report that match for a device, that device will be included in result, no matter the timestamp.Queries the latest inserted record for given metrics key, and checks if it matches the filter.
Includes a simple little functionality for testing in browser, just add params like
?metric=cpu_temp&metric_operator=gt&metric_value=37.0
to devices URL.