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 +4 -4
- data/lib/hisui/request.rb +4 -4
- data/lib/hisui/response.rb +37 -0
- data/lib/hisui/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40023cc074221349d9cad623cd2caaac5e2ffb88e67034898369f66b7fc816c9
|
4
|
+
data.tar.gz: 25adc10ab95a55e827019fc7dcb602b526c2c9a294dc6cc5e14df44cd4ac079e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac21d837a1d1fbe96652c678e5152ec07678c89a941c31b128268bc875e4121af60ae11abe33f7746ee380a46c846df20f10cc2a5649bcc591e4fa4d4af03539
|
7
|
+
data.tar.gz: f9d20bf6242ee9da3033e52173b9ed7348ef20cdcf0f7906107a09ae4f2b31c5d0116dec8e3741e7572cb803677a9296897c6f0b799690b2a53f91d7533ed93c
|
data/lib/hisui/request.rb
CHANGED
@@ -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, :
|
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, :
|
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
|
28
|
-
date_ranges << Google::Apis::AnalyticsreportingV4::DateRange.new(start_date:
|
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(
|
data/lib/hisui/response.rb
CHANGED
@@ -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|
|
data/lib/hisui/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|