Class: Appstats::TestQuery
- Inherits:
-
Object
- Object
- Appstats::TestQuery
- Defined in:
- lib/appstats/test_query.rb
Instance Attribute Summary collapse
-
#group_query_to_sql ⇒ Object
Returns the value of attribute group_query_to_sql.
-
#query ⇒ Object
Returns the value of attribute query.
-
#query_to_sql ⇒ Object
Returns the value of attribute query_to_sql.
Instance Method Summary collapse
Instance Attribute Details
#group_query_to_sql ⇒ Object
Returns the value of attribute group_query_to_sql.
5 6 7 |
# File 'lib/appstats/test_query.rb', line 5 def group_query_to_sql @group_query_to_sql end |
#query ⇒ Object
Returns the value of attribute query.
5 6 7 |
# File 'lib/appstats/test_query.rb', line 5 def query @query end |
#query_to_sql ⇒ Object
Returns the value of attribute query_to_sql.
5 6 7 |
# File 'lib/appstats/test_query.rb', line 5 def query_to_sql @query_to_sql end |
Instance Method Details
#db_connection ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/appstats/test_query.rb', line 12 def db_connection if query.host == "otherServer" dbconfig = YAML::load(File.open('db/config.yml')) ActiveRecord::Base.establish_connection(dbconfig['development']).connection else Appstats.connection end end |
#process_query ⇒ Object
7 8 9 10 |
# File 'lib/appstats/test_query.rb', line 7 def process_query query.query_to_sql = "select count(*) as num from appstats_test_objects" query.group_query_to_sql = "select context_key_filter, context_value_filter, count(*) as num from (select 'name' as context_key_filter, name as context_value_filter from appstats_test_objects) results group by context_value_filter" end |