Class: GAShikomi::Subcommand::Ga
- Defined in:
- lib/ga_shikomi/subcommand/ga.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#_raw_get(config) ⇒ Object
allow recursive call.
-
#get(config) ⇒ Object
require –profile-id –begin-date –end-date –metrics.
Methods inherited from Base
Constructor Details
This class inherits a constructor from GAShikomi::Subcommand::Base
Instance Method Details
#_raw_get(config) ⇒ Object
allow recursive call
- param
-
Hash
- return
-
Hash
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ga_shikomi/subcommand/ga.rb', line 29 def _raw_get(config) opts = { 'ids' => ['profile_id'], 'start-date' => ['start_date'], 'end-date' => ['end_date'], 'metrics' => ['metrics'] } %w(ids metrics dimensions filters max-results output samplingLevel segment sort start-index fields).each {|e| opts[e] = config[e] if config[e] } if config result = api.execute(api.analytics.data.ga.get, opts) if result['nextLink'] query = result['query'] start = query['start-index'] limit = query['max-results'] rows = result['rows'] config['start-index'] = start + limit result = _raw_get(config) result['rows'] += rows end result end |
#get(config) ⇒ Object
require –profile-id –begin-date –end-date –metrics
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ga_shikomi/subcommand/ga.rb', line 10 def get(config) result = _raw_get(config) case result['rows'].size when 1 [result['totalsForAllResults']] else fields = %w(columnHeaders totalsForAllResults rows) fields.map {|e| {e => result[e]}}.reduce(:merge) end end |