-
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 support for filtering devices on alarms #1628
Conversation
query_current_alarms(product_id) | ||
|> Repo.all() | ||
|> Enum.map(fn %{data: data} -> | ||
Map.keys(data["alarms"]) |
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.
Currently in this format: Elixir.NervesHubHealth.HealthCheckFailed
We could make them more human friendly perhaps?
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.
Using inspect/1
on the alarm name will pretty print without Elixir.
- We could also add a helper in DeviceHealth.save/1
to preemptively adjust/cast :alarms
keys into the prettier format
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'm wondering if we also remove NervesHubHealth
?
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.
Oh, it's Elixir.NervesHubHealth.HealthCheckFailed
actually so solved it by splitting on dots and using the last item.
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.
Will there be more alarms in the future? We have lots of alarms not explicitly scoped to NervesHubHealth
. I'm not sure if that's the only thing expected to be reported here though the name alarms
seems to suggest it might
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.
From what I understand the alarm functionality will be built out, and separated into it's own context/db table. This function will need an update then :)
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.
NervesHubHealth came from the separate library that we won't be shipping. We can go forward with whatever naming we prefer.
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 agree with using inspect/1
to get it without the Elixir prefix :)
Does trimming the Elixir. help with fitting? I don't think we want it anyway. Also, I really like this feature. I'm quite excited about using it. |
query_current_alarms(product_id) | ||
|> Repo.all() | ||
|> Enum.map(fn %{data: data} -> | ||
Map.keys(data["alarms"]) |
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'm wondering if we also remove NervesHubHealth
?
""" | ||
def query_devices_with_alarms() do | ||
(lr in subquery(latest_row_query())) | ||
|> from() |
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.
Is this from()
needed?
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.
Yes, otherwise the lr
variable is undefined according to compiling errors. It's something with starting the pipes with this lr in..
that I don't like.. that's why the queries aren't pipe-only. But I get why you want them all to be in the same format
lib/nerves_hub/devices/alarms.ex
Outdated
Selects latest health per device if alarms is populated and device belongs to product. | ||
""" | ||
def query_current_alarms(product_id) do | ||
from( |
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.
Can you please switch these to pipe queries.
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 can! I found this way easier to follow somehow
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.
This is a solid step forward!
So the NervesHubHealth prefix for the alarm is entirely up to the thing making the alarm. We can decide if we want a different convention in the default alarms for NervesHubLink as we won't be shipping the NervesHubHealth library. It got folded into NervesHubLink's features implementation. |
Use pipes only in alarm queries
3620bd1
to
c16c3ad
Compare
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.
Looks great to me. Some of the Ecto bits are bending my brain, but I think we can try this out in prod and improve from there.
@joshk this should be ready now! |
Awesome work @elinol ! |
Adds filtering support for:
Also adds alarm counter on product dashboard with link to filtered devices list.