<%= form_for @check, html: {class: "small-form"} do |f| %> <% unless @check.respond_to?(:check_type) || @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 %>
<%= 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" %>
<% if Blazer.slack? %>
<%= f.label :slack_channels %> <%= f.text_field :slack_channels, placeholder: "Optional, comma separated", class: "form-control" %>
<% end %>

Emails <%= Blazer.slack? ? "and Slack notifications " : nil %>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" %> <%= link_to "Back", :back, class: "btn btn-link" %>

<% end %>