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: nil, **options) ⇒ Object
- .filtered_results(key_and_email: 'config/key_and_email.yml', private_key: nil, client_email: nil) ⇒ Object
- .filtering(results) ⇒ Object
-
.ga_profile(key_and_email, private_key:, client_email:) ⇒ Object
TODO: should specify by profile id, too.
-
.query_parameters(model_config, **options) ⇒ Object
HACK: not cool descriptions.
- .raw_results(key_and_email, private_key:, client_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: nil, **options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 9 def configure(report_config: 'config/ga_reporting_config.yml', filters: nil, **) # TODO: oh... global variable... $model_config = YAML.load_file(report_config) if filters.nil? $filters_file = File.('../config/filters.rb', __FILE__) else $filters_file = filters end require 'simple_ga_reporting/legato_ga_model' query_parameters($model_config, ) end |
.filtered_results(key_and_email: 'config/key_and_email.yml', private_key: nil, client_email: nil) ⇒ Object
23 24 25 26 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 23 def filtered_results(key_and_email: 'config/key_and_email.yml', private_key: nil, client_email: nil) raw_results = raw_results(key_and_email, private_key: private_key, client_email: client_email) filtering(raw_results) end |
.filtering(results) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 44 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, private_key:, client_email:) ⇒ Object
TODO: should specify by profile id, too
55 56 57 58 59 60 61 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 55 def ga_profile(key_and_email, private_key:, client_email:) ga_user = create_ga_user(key_and_email, private_key: private_key, client_email: client_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
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 64 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, private_key:, client_email:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/simple_ga_reporting/simple_ga_reports.rb', line 28 def raw_results(key_and_email, private_key:, client_email:) # 'legato_ga_model' method is generated by Model class automatically query = ga_profile(key_and_email, private_key: private_key, client_email: client_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 |