Skip to content
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

Default to a 0 evaluation frequency in dwh alerts #678

Merged
merged 1 commit into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions app/controllers/miq_policy_controller/alerts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,14 @@ def alert_build_edit_screen
end

def alert_default_repeat_time
(@edit[:new][:expression][:eval_method] && @edit[:new][:expression][:eval_method] == "hourly_performance") ||
@edit[:new][:exp_event] == "_hourly_timer_" ?
1.hour.to_i : 10.minutes.to_i
if (@edit[:new][:expression][:eval_method] && @edit[:new][:expression][:eval_method] == "hourly_performance") ||
@edit[:new][:exp_event] == "_hourly_timer_"
1.hour.to_i
elsif @edit[:new][:expression][:eval_method] && @edit[:new][:expression][:eval_method] == "dwh_generic"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moolitayer Are you able to check :always_evaluate here instead? This way the Ui code can also be generic.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI code does not send or knows about :always_evaluate, that is only on the server side

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gtanzillo PTAL

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gtanzillo Please take another look.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood @moolitayer

0.minutes.to_i
else
10.minutes.to_i
end
end

def alert_get_perf_column_unit(val)
Expand Down Expand Up @@ -488,6 +493,11 @@ def alert_build_pulldowns
2.hours.to_i => _("2 Hours"), 3.hours.to_i => _("3 Hours"), 4.hours.to_i => _("4 Hours"),
6.hours.to_i => _("6 Hours"), 12.hours.to_i => _("12 Hours"), 1.day.to_i => _("1 Day")
}

# repeat times for Notify Datawarehouse pull down
@sb[:alert][:repeat_times_dwh] ||= {
0.minutes.to_i => _("Always Notify")
}
end

def alert_build_ems_alarms
Expand Down
11 changes: 10 additions & 1 deletion app/views/miq_policy/_alert_details.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,17 @@
%p.form-control-static
= h(@event)
-# Repeat Time
.form-group
.form-group.notification-frequency
%label.control-label.col-md-2
= _("Notification Frequency")
- hide = false
- if @edit
.col-md-8
- if @edit[:new][:expression][:eval_method] == "hourly_performance"
- repeat = @sb[:alert][:hourly_repeat_times]
- elsif @edit[:new][:expression][:eval_method] == "dwh_generic"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - would be better if you can check :always_evaluate here.

- repeat = @sb[:alert][:repeat_times_dwh]
- hide = true
- else
- repeat = @sb[:alert][:repeat_times]
= select_tag('repeat_time',
Expand All @@ -121,8 +125,13 @@
%p.form-control-static
- if @alert.options[:notifications][:delay_next_evaluation].blank?
= _('10 Minutes')
- elsif @alert.options[:notifications][:delay_next_evaluation].zero?
- hide = true
- else
= h(@sb[:alert][:repeat_times][@alert.options[:notifications][:delay_next_evaluation]])
- if hide
:javascript
$(".notification-frequency").hide();
%hr
-# Expression
- if @edit
Expand Down