Code Monkey home page Code Monkey logo

garb's Introduction

garb's People

Contributors

reagent avatar tpitale avatar viget avatar zapnap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

garb's Issues

Research new GA features

Research the new GA features (e.g., intelligence, goals, events) to determine if there is an API around this data.

undefined method `camelize' for "goal"

Hey, I can authenticate ok, but get the following error when I try to access the Account or Profile features. Any ideas?

/Users/dan/.rvm/gems/ruby-1.8.7-p174/gems/garb-0.7.6/lib/garb.rb:36:in to_ga': undefined methodcamelize' for "goal":String (NoMethodError)
from /Users/dan/.rvm/gems/ruby-1.8.7-p174/gems/garb-0.7.6/lib/garb/profile.rb:12:in initialize' from /Users/dan/.rvm/gems/ruby-1.8.7-p174/gems/garb-0.7.6/lib/garb/profile.rb:24:innew'
from /Users/dan/.rvm/gems/ruby-1.8.7-p174/gems/garb-0.7.6/lib/garb/profile.rb:24:in all' from /Users/dan/.rvm/gems/ruby-1.8.7-p174/gems/garb-0.7.6/lib/garb/profile.rb:24:inmap'
from /Users/dan/.rvm/gems/ruby-1.8.7-p174/gems/garb-0.7.6/lib/garb/profile.rb:24:in all' from /Users/dan/.rvm/gems/ruby-1.8.7-p174/gems/garb-0.7.6/lib/garb/profile.rb:28:infirst'

Improve filtering (querying) interface

Okay, I've really started to use this for some crazy GA work, and the api around filtering on an existing report class really sucks, and there's no reason to make a one-off report just to have filtering.

Fix it!

Report results bleed on classes

This may seem confusing, but it resulted in much more confusion on my end, so hopefully it makes sense. When you use extend Garb::Model and call results, these results bleed across multiple results calls with different filters.

I had this code:

module BrowserUsage

  class BrowserName
    extend Garb::Model
    dimensions :browser
    metrics :visits
  end

  class BrowserVersion
    extend Garb::Model
    dimensions :browser_version
    metrics :visits
  end

  def self.browser_name_results(profile)
    BrowserName.results(profile)
  end

  def self.browser_version_results(profile, browser)
    BrowserVersion.results(profile) do
      filters :browser.eql(:browser, browser)
    end
  end
end

When calling BrowserUsage.browser_version_results(profile, 'Firefox') and then calling BrowserUsage.browser_version_results(profile, 'Safari') — you'll end up with the same amount of visits on both result sets.

I've fixed this locally by just using the one-off reports that now work (yay!), but it's something that definitely made me pretty confused trying to figure out why my data was wrong.

google authsub

Is there a possibility to integrate garb sessions with google authsub sessions?

"Accounts URL did not end in /default"

very simple example was working before

require 'rubygems'
require 'garb'
require 'postgres'
require 'ruby-debug'
class Analytics
include Garb::Resource
Garb::Session.login(username, password)
Garb::Account.all
end

produces the following

/Library/Ruby/Gems/1.8/gems/garb-0.2.5/lib/garb/data_request.rb:24
raise response.body.inspect unless response.is_a?(Net::HTTPOK)
RuntimeError: "Accounts URL did not end in /default"
method send_request in data_request.rb at line 24
method all in profile.rb at line 46
method all in account.rb at line 12
at top level in analytics.rb at line 8

collection of segments by name/id

If the user of garb knows the segment ids, they should be able to reference that id by name in multiple reports, without having to use the id #.

Example usage:

Garb.available_segments = {:not_new_york => 0}

report = Garb::Report.new(profile)
report.segment :not_new_york
report.metrics :pageviews
pp report.results

results returning as array, not openstruct or hash

I seem to be getting arrays for my results, rather than an ostruct.

Example:

class Reports

  def things
    report = Garb::Report.new($profile)
    report.metrics :pageviews
    thing = report.results

snip
puts thing.pageviews => in things': undefined methodpageviews' for [#]:Array (NoMethodError)

puts report.results.inspect  => [#<OpenStruct pageviews="10">]

puts thing => #<OpenStruct pageviews="10">

puts thing[0] => #<OpenStruct pageviews="10">

Sorry new to ruby and reporting this sort of thing - apologies if this is an obvious error on my part, or if this is the wrong way to report.

NoMethodError for gmail account without any google analytics accounts

Hey,

'NoMethodError' was thrown when I tried to call Garb::Profile.all(no google analytics account in my gmail account), the following is the code used to access google analytics data:

access_token, access_secret = user.access_tokens.last
Garb::Session.access_token = OAuth::AccessToken.new(GoogleAuth.consumer, access_token, access_secret)
profiles = Garb::Profile.all

And here is the backtrace:

from /Users/bob/.rvm/gems/ruby-1.8.7-p249/gems/garb-0.8.4/lib/garb/profile.rb:10:in initialize' from /Users/bob/.rvm/gems/ruby-1.8.7-p249/gems/garb-0.8.4/lib/garb/profile.rb:25:innew'
from /Users/bob/.rvm/gems/ruby-1.8.7-p249/gems/garb-0.8.4/lib/garb/profile.rb:25:in all' from /Users/bob/.rvm/gems/ruby-1.8.7-p249/gems/garb-0.8.4/lib/garb/profile.rb:25:inmap'
from /Users/bob/.rvm/gems/ruby-1.8.7-p249/gems/garb-0.8.4/lib/garb/profile.rb:25:in `all'

I think we need to return an empty array if there are no any google analytics accounts.

Thanks.

Sean

NoMethodError: undefined method `string' for XMLParser:Class

I'm able to successfully create a Garb::Session but then I run into a problem:

Garb::Account.all
NoMethodError: undefined method string' for XMLParser:Class from /Library/Ruby/Gems/1.8/gems/happymapper-0.3.0/lib/happymapper.rb:75:inparse'
from /Library/Ruby/Gems/1.8/gems/garb-0.7.0/lib/garb/profile.rb:50:in all' from /Library/Ruby/Gems/1.8/gems/garb-0.7.0/lib/garb/account.rb:14:inall'
from (irb):2

I can't, for the life of me, figure out when this started occurring and/or how to start debugging. Any help?

can't create multiple filters against the same target with the same method

Because the < and > operators don't work against dimensions, in order to build ranges targeting dimensions such as daysSinceLastVisit, one would like to do something akin to


filters do
  [1..7].each {|i| eql(:days_since_last_visit, i) }
end

Because Garb uses a hash to store the filters, and keys that hash on the (target, operator) pair, doing this appears to be impossible.

Thoughts?

AND/OR filtering

I see the README says that documentation for AND/OR is on the TODO, but I think that the DSL might not be currently capable of properly OR filtering.

The following works.... but how do you generate it programmatically? I can't build a Ruby Hash of duplicate keys.

report.filters({:page_path.eql => 'index', :page_path.eql => 'home'})

So I try the block method

report.filters do
    ['index', 'home'].each do |path|
        eql(:page_path, path)
    end
end

But that ends up using the AND operator: filters=ga:pagePath%3D%3Dindex;ga:pagePath%3D%3Dhome

So I try the next obvious thing:

report.filters do
    eql(:page_path, ['index', 'home'])
end

But that just results in filters=ga:pagePath%3D%3Dindexhome when it should be filters=ga:pagePath%3D%3Dindex,ga:pagePath%3D%3Dhome

Anyone get this working or should we rework this part of the DSL?

garb conflict with rails

when using has_one association and try to eager load using :include you get the following errror
NoMethodError (undefined method `macro' for #RealEstate:0x227f798):
The conflict happens @ ActiveRecord::AssociationPreload::ClassMethods in preload_one_association where the function uses group_by function on an array. Garb redefines the array group_by function which causes the problem.

Tests failing

I tried to run the tests via 'rake test' but it fails with the error

/usr/local/bin/ruby -I"lib:test" "/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "test/unit/garb/account_test.rb"   "test/unit/garb/authentication_request_test.rb" "test/unit/garb/data_request_test.rb" "test/unit/garb/filter_parameters_test.rb" "test/unit/garb/oauth_session_test.rb"     "test/unit/garb/operator_test.rb" "test/unit/garb/profile_test.rb" "test/unit/garb/report_parameter_test.rb" "test/unit/garb/report_response_test.rb"   "test/unit/garb/report_test.rb" "test/unit/garb/resource_test.rb" "test/unit/garb/session_test.rb" "test/unit/garb_test.rb" 
./test/unit/garb/account_test.rb:5: undefined method `context' for Garb::AccountTest:Class (NoMethodError)
from /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/usr/local/bin/ruby -I"lib:test" "/usr/loc...]

I installed the gem minitest but without any success. What's my fault?

Thanks,
Martin

Filter throws exception when used in class context

class Something
  include Garb::Resource
  filter :page_path.contains => /test/
end

gives:

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<
    from /usr/lib/ruby/gems/1.8/gems/vigetlabs-garb-0.2.1/lib/garb/resource.rb:23:in `filter'

Sorting and filtering not working when using search class

example 1:

class Exits
include Garb::Resource
metrics :pageviews, :exits
dimensions :request_uri
end

pp Exits.results(profile) do
filter :exits.gte => 100
sort :exits.desc
end

it gave wrong result (not sorted, not filtred):
[#<OpenStruct pageviews="767", exits="150", request_uri="/">,
#<OpenStruct pageviews="276", exits="42", request_uri="/atrakcje.html">]

but when i do:

report = Garb::Report.new(profile, :limit => 2)
report.metrics :pageviews, :exits
report.dimensions :request_uri
report.filter :exits.gte => 100
report.sort :exits.desc
pp report.results

result is correct:

[#<OpenStruct pageviews="563", exits="172", request_uri="/galeria.html">,
#<OpenStruct pageviews="767", exits="150", request_uri="/">]

did i do something wrong or it's a bug ?

Custom segments support?

Hi - thanks for a great gem - been using this in my first programming attempt ever, and it's been going well.

However, I got sent some new requests for my script, that I can only picture working (nicely) if I use segments.

The API feed query exporter allows me to use these like this:

segment=gaid::95904094

But a search through the GARB source and docs makes me think there's no support for this in GARB - is this right?

In either case, cheers for your work; and for answering what I can now see was a pretty obvious question a few months back...

Undefined method `camelize` for "goal":String

My test file:

require 'rubygems'
require 'garb'
username = '***'
password = '***'
Garb::Session.login(username, password)
Garb::Account.all

Error:

/home/lamnk/.rvm/gems/ruby-1.8.7-p302/gems/garb-0.7.6/lib/garb.rb:36:in `to_ga': undefined method `camelize' for "goal":String (NoMethodError)
from /home/lamnk/.rvm/gems/ruby-1.8.7-p302/gems/garb-0.7.6/lib/garb/profile.rb:12:in `initialize'
from /home/lamnk/.rvm/gems/ruby-1.8.7-p302/gems/garb-0.7.6/lib/garb/profile.rb:24:in `new'
from /home/lamnk/.rvm/gems/ruby-1.8.7-p302/gems/garb-0.7.6/lib/garb/profile.rb:24:in `all'
from /home/lamnk/.rvm/gems/ruby-1.8.7-p302/gems/garb-0.7.6/lib/garb/profile.rb:24:in `map'
from /home/lamnk/.rvm/gems/ruby-1.8.7-p302/gems/garb-0.7.6/lib/garb/profile.rb:24:in `all'
from /home/lamnk/.rvm/gems/ruby-1.8.7-p302/gems/garb-0.7.6/lib/garb/account.rb:14:in `all'
from test.rb:10

undefined method `closed?' for nil:NilClass

Upon attempting to login, I receive the following error from Garb. See my irb session:

  irb(main):001:0> require 'rubygems'
  => true
  irb(main):002:0> require 'garb'
  => true
  irb(main):003:0> Garb::Session.login("login", "pass")
  NoMethodError: undefined method `closed?' for nil:NilClass
  from /usr/lib/ruby/1.8/net/http.rb:1060:in `request'
  from /usr/lib/ruby/gems/1.8/gems/garb-0.8.0/lib/garb/authentication_request.rb:36:in `send_request'
  from /usr/lib/ruby/gems/1.8/gems/garb-0.8.0/lib/garb/authentication_request.rb:49:in `auth_token'
  from /usr/lib/ruby/gems/1.8/gems/garb-0.8.0/lib/garb/session.rb:10:in `login'
  from (irb):3
  from /usr/local/lib/site_ruby/1.8/rubygems/exceptions.rb:8

I am running Ruby 1.8.7 and have tried with ActiveSupport 3.0.0 and 2.3.8. My crack version is 0.1.8

EDIT: It seems this error is only happening when the user/pass is incorrect.

Multiple filters don't work with OAuth

The following code results in a 401 (Unknown authorization header) from GA, but works fine when using Garb::Session.login. The problem seems to be fixed by 32c3eb6.

(You'll need to set 'token' and 'secret' to run the code below, but it should otherwise work as-is.)

I suspect that the problem is that the OAuth gem is not escaping semicolons when constructing the canonical URL, but Google are escaping them when checking the signature - this explains why we only trip up when there are semicolons in the URL (for example when using multiple filters).

#!/usr/bin/env ruby

require 'rubygems'
require 'oauth'
require 'garb'

consumer = OAuth::Consumer.new('anonymous', 'anonymous', {
  :site => 'https://www.google.com',
})

Garb::Session.access_token = OAuth::AccessToken.new(consumer, token, secret)

profile = Garb::Account.all.first.profiles.first

class Visits
  extend Garb::Resource

  metrics :visits

  filters do
    contains(:keyword, 'your')
    eql(:medium, 'cpc')
  end
end

results = Visits.results(profile)

0.7.4 errors on empty results

I tried to get a report for a campaign that does not exist.
In 0.7.2 the result was just an empty array (which I think is good),
The new version results in the following error when I try to get the results:

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
/var/lib/gems/1.8/gems/garb-0.7.4/lib/garb/report_response.rb:30:in values_for' /var/lib/gems/1.8/gems/garb-0.7.4/lib/garb/report_response.rb:30:in map' /var/lib/gems/1.8/gems/garb-0.7.4/lib/garb/report_response.rb:30:in values_for' /var/lib/gems/1.8/gems/garb-0.7.4/lib/garb/report_response.rb:16:in parse' /var/lib/gems/1.8/gems/garb-0.7.4/lib/garb/report_response.rb:15:in map' /var/lib/gems/1.8/gems/garb-0.7.4/lib/garb/report_response.rb:15:in parse' /var/lib/gems/1.8/gems/garb-0.7.4/lib/garb/report_response.rb:10:in results' /var/lib/gems/1.8/gems/garb-0.7.4/lib/garb/resource.rb:54:in results

Wrong Number of Arguments 1 for 0

Having a problem using the start_date and end_date parameters. After struggling for a bit, I copied and pasted in this code directly from: http://www.viget.com/extend/updated-garb-even-easier-access-to-the-google-analytics-api/

report.results(:limit => 10,
:offset => 20,
:start_date => (Date.today - 30),
:end_date => Date.today)

And I still have the problem. Thanks for any help!

Processing StatsController#index (for 127.0.0.1 at 2009-06-02 12:40:51) [GET]
Parameters: {"action"=>"index", "controller"=>"stats"}

ArgumentError (wrong number of arguments (1 for 0)):
/app/models/stats.rb:32:in results' /app/models/stats.rb:32:ingenerateStats'
/app/controllers/stats_controller.rb:4:in index' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:insend'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in perform_action_without_filters' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:incall_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in perform_action_without_benchmark' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:inperform_action_without_rescue'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in measure' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:inperform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in perform_action_without_caching' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:inperform_action'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in cache' /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/query_cache.rb:8:incache'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:12:in perform_action' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:insend'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:524:in process_without_filters' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:606:inprocess_without_session_management_support'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/session_management.rb:134:in process' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:392:inprocess'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:183:in handle_request' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:110:indispatch_unlocked'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:123:in dispatch' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:insynchronize'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:122:in dispatch' /Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:132:indispatch_cgi'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:39:in dispatch' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:inprocess'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in synchronize' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:inprocess'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in process_client' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:ineach'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in process_client' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:inrun'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in initialize' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:innew'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:ininitialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in new' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:inrun'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:ineach'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:inrun'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in run' /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:inload_without_new_constant_marking'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in load' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:innew_constants_in'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:142:in load' /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/commands/servers/mongrel.rb:64 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in require' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:inrequire'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in new_constants_in' /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:inrequire'
/Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in gem_original_require' /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:inrequire'
script/server:3

Fails on JRuby

Does not install on JRuby as it cannot build native extensions. I guess it should be the happymapper that has native extensions?
After some digging i find that libxml-ruby which is required by HappyMapper is the problem so it is an issue of HappyMapper

Session should store accounts

As a method of "caching" the accounts, so the profiles do not need to be re-requested, a session should store an instance variable collection of accounts.

problem retrieving data

Hi,

I'm new to the usage of gard in ror. Currently I'm having some problem getting the data from GA as the openstruct returns a empty table,

My code is:

class AnalyticsController < ApplicationController
include Garb
def index
Session.login('xxx', 'xxx')
@Profile = Profile.all.detect{|p| p.table_id == 'xxxxx'.to_ga}
@results = Hits.results(@Profile)# do

end
end

class Hits
include Garb::Resource
metrics :pageviews
dimensions :pagepath
end

When printing out as <% debug @results %> here is what i get

  • !ruby/object:OpenStruct
    table: {}
  • !ruby/object:OpenStruct
    table: {}
  • !ruby/object:OpenStruct
    table: {}
  • !ruby/object:OpenStruct
    table: {}

I'm not very sure which part went wrong, but hope someone can give me some guidance. Could it be something to do with the namespace issue?

Authentication type should just be "GOOGLE"

In authentication_request.rb, the parameter 'accountType' should be 'GOOGLE', not 'HOSTED_OR_GOOGLE'.

This will make this library work with Google Apps hosted emails that also have an Analytics account (or else Google will log me in the hosted "gmail" account, rather than the "google" analytics account).

So just change the accountType to "GOOGLE" or allow me to pass a parameter to do so...

undefined method ‘mattr_accessor’ for ActiveSupport::Deprecation:Module

Getting this error

undefined method ‘mattr_accessor’ for ActiveSupport::Deprecation:Module

For this script:

# require "active_support"
require "garb"

class Exits
  extend Garb::Resource

  metrics :exits, :pageviews
  dimensions :page_path
  sort :exits
end

Garb::Session.login("XXXX", "XXXX")
profile = Garb::Profile.first('XXXXX')
pp Exits.results(profile)

Adding require "active_support" seemed to fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.