-
Notifications
You must be signed in to change notification settings - Fork 897
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 a new event group level #17611
Add a new event group level #17611
Conversation
I'm not sure who best to review this, maybe @gmcculloug or @lfu ? |
@agrare no problem. Thank you 👍 |
app/models/event_stream.rb
Outdated
level = v[:detail].include?(event_type) ? :detail : :critical | ||
level = :detail # the level is detail as default | ||
group = event_groups.find do |_k, value| | ||
lvl_found = GROUP_LEVELS.detect { |lvl| value[lvl]&.include?(event_type) } |
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 &
a typo here?
Where are the warning
events defined? Otherwise value[:warning]
returns nil
.
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.
hey &
not is a typo, this handle new values and avoid the flow be stopped when occurs nil.include?
. Also we can define warning events in the settings.yml
for each provider and I will open a PR to add warning events in the provider lenovo after this PR be merged.
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.
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.
@CharlleDaniel Could you please write some test cases to ensure the format of the return value is the same as before?
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.
@lfu ok, no problem.
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.
@lfu done, the tests were created.
ac19bad
to
45bbdd3
Compare
app/models/event_stream.rb
Outdated
group = event_groups.find do |_k, value| | ||
lvl_found = GROUP_LEVELS.detect { |lvl| value[lvl]&.include?(event_type) } | ||
level = lvl_found if lvl_found # update the level variable if found the current level. | ||
lvl_found # the level found or nil |
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.
How about this?
def self.group_and_level(event_type)
group, value = event_groups.detect { |_k, v| GROUP_LEVELS.any? { |g| v[g]&.include?(event_type) } }
if group.nil?
group, level = :other, :detail
else
level = GROUP_LEVELS.detect { |g| value[g].include?(event_type) }
end
return group, level
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.
@lfu This works, but I think that is more complex, cause you need to do one more iteration. So I prefer the another form, but thank you.
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.
It can be simplified as:
def self.group_and_level(event_type)
level = :detail # the level is detail as default
group, _ = event_groups.find do |_k, value|
GROUP_LEVELS.detect { |lvl| value[lvl]&.include?(event_type) }.tap do |level_found|
level = level_found if level_found
end
end
group ||= :other
return group, level
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 liked this and changed the code to your suggestion, thank you 😄 .
app/models/event_stream.rb
Outdated
group[:name] | ||
return if group.nil? | ||
group = event_groups[group] | ||
group.nil? ? 'Other' : group[:name] |
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 method used to support passed in group as a string and it returns nil
if group is nil
.
Is it intentional to change the behavior?
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 we also add test cases here to ensure the behavior is not changed accidentally?
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 method used to support passed in group as a string and it returns nil if group is nil.
Is it intentional to change the behavior?
@lfu Good point, it is a symbol, but I will add the group.sym
again because the group column have a type as string( Line 31 ) and when persisted in the virtual column it is converted as string. Someone can do EventStream.group
, receive a string and try get the group_name passing the string as param.
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 we also add test cases here to ensure the behavior is not changed accidentally?
I think the tests already cover this case.
@dclarizio @h-kataria Wondering if this PR would have any impact on the timeline UI. |
56c9c08
to
ec410eb
Compare
@lfu I tested the timeline and everything looks good. |
@CharlleDaniel @lfu the new Group level "Warning" being added in this PR will not show up in UI unless changes are made in UI code to show/support the new level. Currently timeline options screen only shows Critical and Detail group level events only. This will require some UI work to show events from "Warning" group level. |
ec410eb
to
be7834d
Compare
Checked commit CharlleDaniel@be7834d with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@lfu Morning, if you not have more suggestion could you to approve this PR 😅 ? I will open a PR adding support to filter warning events on the UI today or tomorrow. |
@CharlleDaniel Can you comment on the questions raise here #17611 (comment) ? |
@gmcculloug and @h-kataria about this comment, all providers are able to use the new group level if they want. Otherwise there are providers that not have events_groups or not need to use this new group level, but the group levels (new and old) not break the provider flow. Also, I will open a PR adding support to filter warning events on the UI today or tomorrow. |
@gmcculloug morning, if you not have more discussions, could you approve this PR? 😅 |
@CharlleDaniel if a provider does not support the new group level, will the new level still show up in UI, it will not yield any timeline results in that case since there wont be any event groups under that, correct? |
@h-kataria hey morning,
Yes, but we can see the same case in categories field, always showing all categories even if provider do not have any event in it. |
👍 |
This PR is able to :
warning
group_level, that the user can filter warning events on the API.