Business intelligence made simple
Merge branch 'cancel'
Andrew Kane4b46ced88773
diff --cc lib/blazer/adapters/sql_adapter.rbindex cf98afc6,a5e34177..9d713e0a--- a/lib/blazer/adapters/sql_adapter.rb+++ b/lib/blazer/adapters/sql_adapter.rb@@@ -72,10 -72,21 +72,21 @@@ module Blazenilend+ def cancel(run_id)+ if postgresql?- execute("SELECT pg_cancel_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND query LIKE '%,run_id:#{run_id}%'")++ select_all("SELECT pg_cancel_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND query LIKE '%,run_id:#{run_id}%'")+ elsif redshift?- first_row = connection_model.connection.select_all("SELECT pid FROM stv_recents WHERE status = 'Running' AND query LIKE '%,run_id:#{run_id}%'").first++ first_row = select_all("SELECT pid FROM stv_recents WHERE status = 'Running' AND query LIKE '%,run_id:#{run_id}%'").first+ if first_row- execute("CANCEL #{first_row["pid"].to_i}")++ select_all("CANCEL #{first_row["pid"].to_i}")+ end+ end+ end+protected- def execute(statement)- connection_model.connection.execute(statement)+ def select_all(statement)+ connection_model.connection.select_all(statement)enddef postgresql?diff --cc lib/blazer/data_source.rbindex b9c12d9e,db3387c8..0dfe33ff--- a/lib/blazer/data_source.rb+++ b/lib/blazer/data_source.rb@@@ -109,13 -109,10 +109,14 @@@ module Blazedef run_statement(statement, options = {})run_id = options[:run_id]+ async = options[:async]result = nil- if cache_mode != "off" && !options[:refresh_cache]- result = read_cache(statement_cache_key(statement))+ if cache_mode != "off"+ if options[:refresh_cache]+ clear_cache(statement) # for checks+ else+ result = read_cache(statement_cache_key(statement))+ endendunless result