Permalink
Browse files

add saved query count to queries controller

  • Loading branch information...
1 parent 2162ad3 commit 12362337160afb664e529ecf90a8a870e6812166 Zach Morek committed Nov 13, 2013
@@ -7,6 +7,8 @@ def new
def create
@run_query = RunQuery.new(run_query_params)
+ saved_query = SavedQuery.where(:sql => run_query_params[:sql]).first
+ SavedQuery.increment_counter(:query_count, saved_query.id)
if @run_query.valid?
@query_runner = QueryRunner.new(@run_query.sql)
@@ -0,0 +1,5 @@
+class AddQueryCountToSavedQueries < ActiveRecord::Migration
+ def change
+ add_column :saved_queries, :query_count, :integer
+ end
+end
View
@@ -11,14 +11,15 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20131112220255) do
+ActiveRecord::Schema.define(version: 20131113031955) do
create_table "saved_queries", force: true do |t|
t.string "name"
t.string "description"
t.text "sql"
t.datetime "created_at"
t.datetime "updated_at"
+ t.integer "query_count"
end
end

0 comments on commit 1236233

Please sign in to comment.