Permalink
Browse files

added multi-analysis query

  • Loading branch information...
1 parent b695c08 commit ae7f9863c4e20217ef61a7ba3bfd54709fcea6c9 obie quelland committed Apr 6, 2013
Showing with 23 additions and 2 deletions.
  1. +22 −1 lib/keen/client/querying_methods.rb
  2. +1 −1 spec/keen/client/querying_methods_spec.rb
@@ -1,3 +1,4 @@
+
module Keen
class Client
module QueryingMethods
@@ -141,6 +142,23 @@ def funnel(params)
query(__method__, nil, params)
end
+ # Runs a multi-analysis query
+ # See detailed documentation here:
+ # https://keen.io/docs/data-analysis/multi-analysis/
+ #
+ # NOTE: why isn't multi-analysis listed in the
+ # API Technical Reference?
+ #
+ # @param event_collection
+ # @param params [Hash]
+ # analyses [Hash] (required)
+ # label (required)
+ # analysis_type (required)
+ # target_property (optional)
+ def multi_analysis(event_collection, params)
+ query(__method__, event_collection, params)
+ end
+
private
def query(query_name, event_collection, params)
@@ -177,6 +195,10 @@ def preprocess_params(params)
params[:steps] = MultiJson.encode(params[:steps])
end
+ if params.key?(:analyses)
+ params[:analyses] = MultiJson.encode(params[:analyses])
+ end
+
if params.key?(:timeframe) && params[:timeframe].is_a?(Hash)
params[:timeframe] = MultiJson.encode(params[:timeframe])
end
@@ -196,4 +218,3 @@ def api_query_resource_path(analysis_type)
end
end
end
-
@@ -15,7 +15,7 @@ def query_url(query_name, query_params)
describe "querying names" do
let(:params) { { :event_collection => "signups" } }
- ["minimum", "maximum", "sum", "average", "count", "count_unique", "select_unique", "extraction"].each do |query_name|
+ ["minimum", "maximum", "sum", "average", "count", "count_unique", "select_unique", "extraction", "multi_analysis"].each do |query_name|
it "should call keen query passing the query name" do
client.should_receive(:query).with(query_name.to_sym, event_collection, params)
client.send(query_name, event_collection, params)

0 comments on commit ae7f986

Please sign in to comment.