Business intelligence made simple
Added query to audits
Andrew Kanea29659aebe9e
diff --git a/app/controllers/blazer/queries_controller.rb b/app/controllers/blazer/queries_controller.rbindex 1d044c94..d22b1be5 100644--- a/app/controllers/blazer/queries_controller.rb+++ b/app/controllers/blazer/queries_controller.rb@@ -16,6 +16,7 @@ module Blazerdef index@queries = Blazer::Query.order(:name).includes(:creator)+ @trending_queries = Blazer::Audit.group(:query_id).where("created_at > ?", 2.days.ago).having("COUNT(*) >= 3").uniq.count(:user_id)enddef new@@ -57,9 +58,12 @@ module Blazerprocess_vars(@statement)if @success+ @query = Query.find_by(id: params[:query_id]) if params[:query_id]+# auditif Blazer.auditaudit = Blazer::Audit.new(statement: @statement)+ audit.query = @queryaudit.user = current_user if respond_to?(:current_user)audit.save!end@@ -81,7 +85,6 @@ module Blazerendend- @query = Query.find_by(id: params[:query_id]) if params[:query_id]@filename = @query.name.parameterize if @query@min_width_types = (@rows.first || {}).select{|k, v| v.is_a?(Time) or v.is_a?(String) or smart_columns[k] }.keysdiff --git a/app/models/blazer/audit.rb b/app/models/blazer/audit.rbindex 60f46245..cf4cea6d 100644--- a/app/models/blazer/audit.rb+++ b/app/models/blazer/audit.rb@@ -1,5 +1,6 @@module Blazerclass Audit < ActiveRecord::Basebelongs_to :user+ belongs_to :queryendenddiff --git a/app/views/blazer/queries/index.html.erb b/app/views/blazer/queries/index.html.erbindex 5d9afe72..26ebfae6 100644--- a/app/views/blazer/queries/index.html.erb+++ b/app/views/blazer/queries/index.html.erb@@ -21,6 +21,9 @@<% if query.created_at > 2.days.ago %><small style="font-weight: bold; color: #5cb85c;">NEW</small><% end %>+ <% if @trending_queries[query.id] %>+ <small style="font-weight: bold; color: #f60;">TRENDING</small>+ <% end %></td><td class="creator text-right text-muted"><% if (creator = query.creator) and creator.respond_to?(Blazer.user_name) %>diff --git a/lib/generators/blazer/templates/install.rb b/lib/generators/blazer/templates/install.rbindex cd90e93a..3582c405 100644--- a/lib/generators/blazer/templates/install.rb+++ b/lib/generators/blazer/templates/install.rb@@ -10,6 +10,7 @@ class <%= migration_class_name %> < ActiveRecord::Migrationcreate_table :blazer_audits do |t|t.references :user+ t.references :queryt.text :statementt.timestamp :created_atend