hisui 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f63cc587035f036777979c56d4d39fed2e9f512e126d3809b3a85a7487ff675
4
- data.tar.gz: '08e8bea765cb07fae43410ce041ab2ff38bf4ea51c997240f4fac1b05aed0b83'
3
+ metadata.gz: 40023cc074221349d9cad623cd2caaac5e2ffb88e67034898369f66b7fc816c9
4
+ data.tar.gz: 25adc10ab95a55e827019fc7dcb602b526c2c9a294dc6cc5e14df44cd4ac079e
5
5
  SHA512:
6
- metadata.gz: 4196498ee4b4985e30cbac8391115c78b3a43de0e8cb06273f89b12eaa4cfe27fd64c5357d0c5794a56d2ff0a1be5590aa6067a238c14c54a2890474ef178a6d
7
- data.tar.gz: d69cf054f142c53fee1692253c6d9b4c6b5d8479fbe5aa80b90b10f5c6f669b280585d76645586a5e3ae0ac138795ccdd44ec76ba743b7131875c5af8beef4dd
6
+ metadata.gz: ac21d837a1d1fbe96652c678e5152ec07678c89a941c31b128268bc875e4121af60ae11abe33f7746ee380a46c846df20f10cc2a5649bcc591e4fa4d4af03539
7
+ data.tar.gz: f9d20bf6242ee9da3033e52173b9ed7348ef20cdcf0f7906107a09ae4f2b31c5d0116dec8e3741e7572cb803677a9296897c6f0b799690b2a53f91d7533ed93c
@@ -2,9 +2,9 @@ require 'google/apis/analyticsreporting_v4'
2
2
 
3
3
  module Hisui
4
4
  class Request
5
- BASIC_OPTION_KEYS = [:start_date, :end_date, :compare_start_date, :compare_end_date, :limit]
5
+ BASIC_OPTION_KEYS = [:start_date, :end_date, :comparing_start_date, :comparing_end_date, :limit, :sort]
6
6
 
7
- attr_accessor :profile, :model, :start_date, :end_date, :compare_start_date, :compare_end_date, :limit
7
+ attr_accessor :profile, :model, :start_date, :end_date, :comparing_start_date, :comparing_end_date, :limit
8
8
 
9
9
  def initialize(profile:, model:, **options)
10
10
  @profile = profile
@@ -24,8 +24,8 @@ module Hisui
24
24
  date_ranges = []
25
25
  date_ranges << Google::Apis::AnalyticsreportingV4::DateRange.new(start_date: start_date.to_s, end_date: end_date.to_s)
26
26
 
27
- if compare_start_date && compare_end_date
28
- date_ranges << Google::Apis::AnalyticsreportingV4::DateRange.new(start_date: compare_start_date.to_s, end_date: compare_end_date.to_s)
27
+ if comparing_start_date && comparing_end_date
28
+ date_ranges << Google::Apis::AnalyticsreportingV4::DateRange.new(start_date: comparing_start_date.to_s, end_date: comparing_end_date.to_s)
29
29
  end
30
30
 
31
31
  request = Google::Apis::AnalyticsreportingV4::GetReportsRequest.new(
@@ -55,6 +55,35 @@ module Hisui
55
55
  end
56
56
  end
57
57
 
58
+ def rows
59
+ @rows ||= begin
60
+ rows = []
61
+
62
+ data.rows.each do |row|
63
+ dimension_values = row.dimensions
64
+ primary_data = []
65
+ comparing_data = []
66
+
67
+ row.metrics.first.values.each do |value|
68
+ primary_data << value
69
+ end
70
+
71
+ if row.metrics.second
72
+ row.metrics.second.values.each do |value|
73
+ comparing_data << value
74
+ end
75
+ end
76
+
77
+ rows << {
78
+ dimensions: OpenStruct.new(Hash[dimensions.zip(dimension_values)]),
79
+ primary: OpenStruct.new(Hash[metrics.zip(primary_data)]),
80
+ comparing: OpenStruct.new(Hash[metrics.zip(comparing_data)]) }
81
+ end
82
+
83
+ rows.map { |attributes| OpenStruct.new(attributes) }
84
+ end
85
+ end
86
+
58
87
  def total_values
59
88
  warn "[DEPRECATION] `total_values` is deprecated. Please use `primary_total` instead."
60
89
  primary_total
@@ -78,6 +107,14 @@ module Hisui
78
107
  @column_header ||= response.reports.first.column_header
79
108
  end
80
109
 
110
+ def dimensions
111
+ @dimensions ||= begin
112
+ column_header.dimensions.each_with_object([]) do |dimension, arr|
113
+ arr << Hisui.from_ga_string(dimension)
114
+ end
115
+ end
116
+ end
117
+
81
118
  def metrics
82
119
  @metrics ||= begin
83
120
  column_header.metric_header.metric_header_entries.each_with_object([]) do |metric, arr|
@@ -1,3 +1,3 @@
1
1
  module Hisui
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hisui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ikepon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-26 00:00:00.000000000 Z
11
+ date: 2018-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails