aliased Report.connection

pull/6827/head
jwollert 14 years ago
parent 3893c7d2a6
commit 69e3f08f27
  1. 14
      lib/report.rb
  2. 8
      lib/report/query_utils.rb

@ -18,6 +18,10 @@ class Report < ActiveRecord::Base
@@accepted_properties ||= [] @@accepted_properties ||= []
end end
def self.reporting_connection
ConnectionSwitcher.connection
end
def self.chain_initializer def self.chain_initializer
@chain_initializer ||= [] @chain_initializer ||= []
end end
@ -136,19 +140,19 @@ class Report < ActiveRecord::Base
def hash def hash
report_string = "" report_string = ""
report_string.concat('filters: [') report_string.concat('filters: [')
report_string.concat(filters.map { |f| report_string.concat(filters.map { |f|
f.class.underscore_name + f.operator.to_s + (f.values ? f.values.to_json : "") f.class.underscore_name + f.operator.to_s + (f.values ? f.values.to_json : "")
}.sort.join(', ')) }.sort.join(', '))
report_string.concat(']') report_string.concat(']')
report_string.concat(', group_bys: {') report_string.concat(', group_bys: {')
report_string.concat(group_bys.group_by(&:type).map { |t, gbs| report_string.concat(group_bys.group_by(&:type).map { |t, gbs|
"#{t} : [#{gbs.collect(&:class).collect(&:underscore_name).join(', ')}]" "#{t} : [#{gbs.collect(&:class).collect(&:underscore_name).join(', ')}]"
}.join(', ')) }.join(', '))
report_string.concat('}') report_string.concat('}')
report_string.hash report_string.hash

@ -1,7 +1,7 @@
module Report::QueryUtils module Report::QueryUtils
alias singleton_class metaclass unless respond_to? :singleton_class alias singleton_class metaclass unless respond_to? :singleton_class
delegate :quoted_false, :quoted_true, :to => "engine.connection" delegate :quoted_false, :quoted_true, :to => "engine.reporting_connection"
attr_writer :engine attr_writer :engine
module PropagationHook module PropagationHook
@ -43,7 +43,7 @@ module Report::QueryUtils
# @return [Object] Quoted version # @return [Object] Quoted version
def quote_string(str) def quote_string(str)
return str unless str.respond_to? :to_str return str unless str.respond_to? :to_str
engine.connection.quote_string(str) engine.reporting_connection.quote_string(str)
end end
def current_language def current_language
@ -75,7 +75,7 @@ module Report::QueryUtils
end end
def quoted_date(date) def quoted_date(date)
engine.connection.quoted_date date.to_dateish engine.reporting_connection.quoted_date date.to_dateish
end end
## ##
@ -175,7 +175,7 @@ module Report::QueryUtils
end end
def adapter_name def adapter_name
engine.connection.adapter_name.downcase.to_sym engine.reporting_connection.adapter_name.downcase.to_sym
end end
def cache def cache

Loading…
Cancel
Save