hisui 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hisui/request.rb +1 -1
- data/lib/hisui/response.rb +2 -2
- data/lib/hisui/response/ga_data.rb +18 -2
- 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: 3208e00862c06d44baea1a6ab70be93b9a29834b69246e8e95a7f2543031677a
|
4
|
+
data.tar.gz: 4bcc60e4780dd8c7d48402a36b2aa35ec1b69b9d56c1f53c4274c3c310192006
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efedfb4a7eb17259412725397350bdfd3af2cdcdac711495b9b804a7d00b8bbf09c37eeb71cb9879906443255b95a773c2a1da975858258042724f952ae8d0cb
|
7
|
+
data.tar.gz: 8804beedc7a904e8728ee99e5ad8e3f3adbd0d5514bd37d916faad372302559d3615bab6f911a770564ee4eaa933255ced4cfba305bec32399dcf3206498b5d9
|
data/lib/hisui/request.rb
CHANGED
data/lib/hisui/response.rb
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
module Hisui
|
2
2
|
class Response
|
3
3
|
class GaData
|
4
|
-
attr_reader :response
|
4
|
+
attr_reader :response, :date_ranges
|
5
5
|
|
6
|
-
|
6
|
+
DATE_DIMENSIONS = %w[ga:date ga:dateHour ga:dateHourMinute].freeze
|
7
|
+
|
8
|
+
def initialize(response:, request:)
|
7
9
|
@response = response
|
10
|
+
@date_ranges = [Range.new(request.start_date.beginning_of_day, request.end_date.end_of_day), Range.new(request.try(:comparing_start_date).try(:beginning_of_day), request.try(:comparing_end_date).try(:end_of_day))]
|
8
11
|
end
|
9
12
|
|
10
13
|
def construct(ordinal)
|
11
14
|
row_data_struct = Struct.new(*fields)
|
12
15
|
|
13
16
|
data.try(:rows).try(:each_with_object, []) do |row, arr|
|
17
|
+
next if date_indices.present? && date_indices.all? { |index| date_ranges.try(ordinal.to_sym).exclude?(row.dimensions[index].in_time_zone) }
|
14
18
|
row_data = []
|
15
19
|
row.dimensions.each do |dimension|
|
16
20
|
row_data << dimension
|
@@ -97,6 +101,18 @@ module Hisui
|
|
97
101
|
end
|
98
102
|
end
|
99
103
|
|
104
|
+
# NOTE: When dimensions include DATE_DIMENSIONS, Google Analytics data has data to include primary and comparing date range.
|
105
|
+
# This is a method to filter only primary or comparing data.
|
106
|
+
def date_indices
|
107
|
+
@date_indices ||= begin
|
108
|
+
used_date_dimensions = DATE_DIMENSIONS & column_header.dimensions
|
109
|
+
|
110
|
+
used_date_dimensions.each_with_object([]) do |dimension, arr|
|
111
|
+
arr << column_header.dimensions.index(dimension)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
100
116
|
def data
|
101
117
|
@data ||= response.reports.first.data
|
102
118
|
end
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ikepon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|