Fosome / garb

A Ruby wrapper for the Google Analytics API
http://www.viget.com/extend/
655 stars 91 forks source link

Using multiple filters doesn't work as expected #119

Open lpdahito opened 12 years ago

lpdahito commented 12 years ago

I have the following code:

require 'garb'

Garb::Session.login("username", "password")

profile = Garb::Management::Profile.all.detect {|p| p.title == "Admin"}

class PageViews
  extend Garb::Model

  metrics :pageviews
  dimensions :page_path
end

date1 = Date.today - 30
date2 = Date.today

object = PageViews.results(profile, :start_date => date1, :end_date => date2, :filters => [{:page_path.matches => "/home"}, {:page_path.matches => "/about"}])

object.each do |result|
  puts "#{result.page_path} #{result.pageviews}"
end

The output expected from this code should be this:

/about 32
/home 106

Instead, the result I get outputs all the "page_paths" of my website with its number of pageviews:

/ 503
/about 32
/contact 12
/home 106
... etc

What seems to be the problem? How do I fix it?

Thank you,

LP

lpdahito commented 12 years ago

By the way I'm using: Ruby 1.9.2 garb (0.9.1)

cirdes commented 11 years ago

+1