Business intelligence made simple
Add invert option to fail if no results are returned
ryninho4512543e8a37
diff --git a/app/controllers/blazer/checks_controller.rb b/app/controllers/blazer/checks_controller.rbindex dc3fdf0a..c9ee8f3b 100644--- a/app/controllers/blazer/checks_controller.rb+++ b/app/controllers/blazer/checks_controller.rb@@ -41,7 +41,7 @@ module Blazerprivatedef check_params- params.require(:check).permit(:query_id, :emails)+ params.require(:check).permit(:query_id, :emails, :invert)enddef set_checkdiff --git a/app/models/blazer/check.rb b/app/models/blazer/check.rbindex b779f45a..14168f27 100644--- a/app/models/blazer/check.rb+++ b/app/models/blazer/check.rb@@ -13,9 +13,9 @@ module Blazerif error"error"elsif rows.any?- "failing"+ invert ? "passing" : "failing"else- "passing"+ invert ? "failing" : "passing"end# do not notify on creation, except when not passingdiff --git a/app/views/blazer/checks/_form.html.erb b/app/views/blazer/checks/_form.html.erbindex d79dbd4e..485c46b2 100644--- a/app/views/blazer/checks/_form.html.erb+++ b/app/views/blazer/checks/_form.html.erb@@ -1,4 +1,4 @@-<p class="text-muted">Checks are designed to identify bad data. A check fails if there are any results.</p>+<p class="text-muted">Checks are designed to identify bad data. A check fails if there are any results (unless inverted).</p><% if @check.errors.any? %><div class="alert alert-danger"><%= @check.errors.full_messages.first %></div>@@ -14,6 +14,18 @@$("#check_query_id").selectize().parents(".hide").removeClass("hide");</script></div>++ <div class="form-group">+ <%= f.label "Failure criterion?" %>+ <%= f.select :invert, [['Fail if ANY results returned (default)', false], ['Fail if NO results returned (invert)', true]], {}, {id: 'select-invert'} %>+ <script>+ $("#select-invert").selectize({+ create: true,+ sortField: 'text'+ });+ </script>+ </div>+<div class="form-group"><%= f.label :emails %><%= f.text_field :emails, placeholder: "Optional, comma separated", class: "form-control" %>