sguss2024 / google-api-ruby-client

Automatically exported from code.google.com/p/google-api-ruby-client
Apache License 2.0
0 stars 0 forks source link

Google Analytics API: filter with AND is impossible #57

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. @client = Google::APIClient.new (then -> authorize)
2. parameters={"ids"=>"ga:XXXXX", "start-date"=>"2011-07-30", 
"end-date"=>"2012-08-30", "metrics"=>"ga:visits", 
"filters"=>"ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc;ga:source==google"} 
3. reference = Google::APIClient::Reference.new(:api_method => 
analytics.data.ga.get(), :parameters => parameters)
3. request = @client.generate_request(reference)
4. you will see that in request object, the 'filters' parameter is split in 2: 
"filters"=>"ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc", "ga:source"=>"=google"

What is the expected output? 
"filters"=>"ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc;ga:source==google"

What do you see instead?
"filters"=>"ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc", "ga:source"=>"=google"

What version of the product are you using? On what operating system?
- Google Analytics Core reporting API V3
- ruby 1.9.3
- google-api-ruby-client : hedge (git)

Please provide any additional information below.

The problem comes from Faraday (or Google Analytics Core reporting API V3 
syntax for filters) :
1. in Faraday::Utils, DEFAULT_SEP = /[&;] */n
2. so the method ''parse_nested_query" splits the part 
"&filters=ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc;ga:source==google" in {"filters" 
=> "ga:medium=~cpa|cpc|cpm|cpp|cpv|ppc", "ga:source" => "=google"}

One solution would be to open Faraday and edit DEFAULT_SEP (remove the ';'): 
DEFAULT_SEP = /[&] */n
How can we deal with this ?

Original issue reported on code.google.com by aramb...@optimeez.com on 31 Aug 2012 at 9:02

GoogleCodeExporter commented 9 years ago
*sigh*

I really need to have a chat with the rest of the Ruby community on how to 
process URIs.

Original comment by bobaman@google.com on 31 Aug 2012 at 9:05

GoogleCodeExporter commented 9 years ago
I'd like to do what I can to make the appropriate change happen in Faraday. A 
few questions:

1. Is there an issue open in Faraday to reflect that this problem is happening?

2. Is it a typo in the URL that the URL includes "ga:source==google"? Should 
that just be a single equals? That is, is "=google" the value of the 
"ga:source" parameter, or is it "google"?

Thanks!

Original comment by j...@jxf.me on 18 Mar 2013 at 9:00

GoogleCodeExporter commented 9 years ago
See https://github.com/google/google-api-ruby-client/issues/37 for further 
updates

Original comment by sba...@google.com on 8 Apr 2013 at 8:45