<% unless @check.respond_to?(:invert) %>

Checks are designed to identify bad data. A check fails if there are any results.

<% end %> <% if @check.errors.any? %>
<%= @check.errors.full_messages.first %>
<% end %> <%= form_for @check do |f| %>
<%= f.label :query_id, "Query" %>
<%= f.select :query_id, [], {include_blank: true} %>
<% if @check.respond_to?(:check_type) %>
<%= f.label :check_type, "Alert if" %>
<% check_options = [["Any results (bad data)", "bad_data"], ["No results (missing data)", "missing_data"]] %> <% check_options << ["Anomaly (most recent data point)", "anomaly"] if Blazer.anomaly_checks %> <%= f.select :check_type, check_options %>
<% elsif @check.respond_to?(:invert) %>
<%= f.label :invert, "Fails if" %>
<%= f.select :invert, [["Any results (bad data)", false], ["No results (missing data)", true]] %>
<% end %> <% if @check.respond_to?(:schedule) && Blazer.check_schedules %>
<%= f.label :schedule, "Run every" %>
<%= f.select :schedule, Blazer.check_schedules.map { |v| [v, v] } %>
<% end %>
<%= f.label :emails %> <%= f.text_field :emails, placeholder: "Optional, comma separated", class: "form-control" %>

Emails are sent when a check starts failing, and when it starts passing again.

<% if @check.persisted? %> <%= link_to "Delete", check_path(@check), method: :delete, "data-confirm" => "Are you sure?", class: "btn btn-danger" %> <% end %> <%= f.submit "Save", class: "btn btn-success" %>

<% end %>