Class: SimpleGaReports
- Inherits:
-
Object
- Object
- SimpleGaReports
- Extended by:
- LegatoGaUser
- Defined in:
- lib/simple_ga_reporting/simple_ga_reports.rb
Constant Summary
Constants included from LegatoGaUser
LegatoGaUser::AUDIENCE, LegatoGaUser::AUTHORIZE_URL, LegatoGaUser::SCOPE, LegatoGaUser::TOKEN_CREDENTIAL_URI, LegatoGaUser::TOKEN_URL
Class Method Summary collapse
- .configure(report_config: 'config/ga_reporting_config.yml', filters: 'config/filters.rb', **options) ⇒ Object
- .filtered_results(key_and_email: 'config/key_and_email.yml') ⇒ Object
- .filtering(results) ⇒ Object
-
.ga_profile(key_and_email) ⇒ Object
TODO: should specify by profile id, too.
-
.query_parameters(model_config, **options) ⇒ Object
HACK: not cool descriptions.
- .raw_results(key_and_email) ⇒ Object
Methods included from LegatoGaUser
client_email, create_ga_user, private_key
Class Method Details
.configure(report_config: 'config/ga_reporting_config.yml', filters: 'config/filters.rb', **options) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 9 def configure(report_config: 'config/ga_reporting_config.yml', filters: 'config/filters.rb', **) # TODO: oh... global variable... $model_config = YAML.load_file(report_config) $filters_file = filters require 'simple_ga_reporting/legato_ga_model' query_parameters($model_config, ) end |
.filtered_results(key_and_email: 'config/key_and_email.yml') ⇒ Object
18 19 20 21 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 18 def filtered_results(key_and_email: 'config/key_and_email.yml') raw_results = raw_results(key_and_email) filtering(raw_results) end |
.filtering(results) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 39 def filtering(results) if @filters @filters.each do |filter_symbol_name| results = results.send(filter_symbol_name) # TODO: oh... send method... end end results end |
.ga_profile(key_and_email) ⇒ Object
TODO: should specify by profile id, too
50 51 52 53 54 55 56 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 50 def ga_profile(key_and_email) ga_user = create_ga_user(key_and_email) ga_user.profiles.each do |profile| return profile if profile.name === @profile_name end end |
.query_parameters(model_config, **options) ⇒ Object
HACK: not cool descriptions
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 59 def query_parameters(model_config, **) @start_date = [:start_date] ? [:start_date] : model_config['start_date'] @end_date = [:end_date] ? [:end_date] : model_config['end_date'] @limit = [:limit] ? [:limit] : model_config['limit'] # @offset = options[:offset] ? options[:offset] : model_config['offset'] @sort = [:sort] ? [:sort] : model_config['sort'] # Array # @quota_user = options[:quota_user] ? options[:quota_user] : model_config['quota_user'] @sampling_level = [:sampling_level] ? [:sampling_level] : 'HIGHER_PRECISION' # @segment_id = options[:segment_id] ? options[:segment_id] : model_config['segment_id'] @filters = [:filters] ? [:filters] : model_config['filters'] # Array @profile_name = [:profile_name] ? [:profile_name] : model_config['profile_name'] # for RSpec (ummm... not good) { start_date: @start_date, end_date: @end_date, limit: @limit, offset: @offset, sort: @sort, quota_user: @quota_user, sampling_level: @sampling_level, segment_id: @segment_id, filters: @filters, profile_name: @profile_name, } end |
.raw_results(key_and_email) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 23 def raw_results(key_and_email) # 'legato_ga_model' method is generated by Model class automatically query = ga_profile(key_and_email).legato_ga_model query.results( start_date: @start_date, end_date: @end_date, limit: @limit, # offset: @offset, sort: @sort, # quota_user: @quota_user, sampling_level: @sampling_level, # segment_id: @segment_id, ) end |