grepdata_client 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +34 -21
- data/lib/grepdata_client/utils.rb +19 -2
- data/lib/grepdata_client/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GrepdataClient
|
2
2
|
|
3
3
|
Official Ruby client for Grepdata API. More info on GrepData APIs can be found
|
4
|
-
in the [GrepData docs](www.grepdata.com/docs).
|
4
|
+
in the [GrepData docs](https://www.grepdata.com/docs).
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -18,11 +18,11 @@ or if you use a Gemfile:
|
|
18
18
|
The track call allows you to send data into the system, usually from client devices.
|
19
19
|
Setup the client with your public token (token) and the endpoint (default_endpoint),
|
20
20
|
generally either 'prod' or 'qa', to send data. These can be found in
|
21
|
-
[settings](www.grepdata.com/#/settings/account) and
|
22
|
-
[endpoints](www.grepdata.com/#/settings/endpoints) respectively. Each track call
|
21
|
+
[settings](https://www.grepdata.com/#/settings/account) and
|
22
|
+
[endpoints](https://www.grepdata.com/#/settings/endpoints) respectively. Each track call
|
23
23
|
requires a first parameter of event name and a second JSON object with any related
|
24
24
|
dimensions you would like to track along with this event. For more info see
|
25
|
-
[docs for sending data](www.grepdata.com/docs#sending).
|
25
|
+
[docs for sending data](https://www.grepdata.com/docs#sending).
|
26
26
|
|
27
27
|
###Example
|
28
28
|
|
@@ -36,28 +36,39 @@ dimensions you would like to track along with this event. For more info see
|
|
36
36
|
|
37
37
|
Querying data using the GrepData API is almost as simple as sending it. This time
|
38
38
|
the client is configured using the private key (api_key) for your account which can
|
39
|
-
be found in [settings](www.grepdata.com/#/settings/account).
|
39
|
+
be found in [settings](https://www.grepdata.com/#/settings/account).
|
40
40
|
|
41
41
|
|
42
42
|
### Data Query
|
43
43
|
|
44
44
|
Each data request requires a params object including the following fields:
|
45
|
-
+ **datamart** (string):
|
46
|
-
+ **dimensions** (array):
|
47
|
-
+ **
|
48
|
-
+ **
|
49
|
-
+ **
|
50
|
-
+ **
|
51
|
-
+ **
|
45
|
+
+ **datamart** (string - Required): Name of the datamart to query (endpoint name for timeseries data).
|
46
|
+
+ **dimensions** (array - Required): All dimensions to query, be sure to include any dimensions being filtered.
|
47
|
+
+ **computed_dimensions** (JSON array): List of any dimensions which have transformation applied on-the-fly at query time.
|
48
|
+
+ **filters** (JSON): Object containing any filters to apply to the selected dimensions, key is dimension name, value is array of valid options.
|
49
|
+
+ **metrics** (array - Required): All metrics columns you want aggregated and returned.
|
50
|
+
+ **time_interval** (string - Required): Time granularity to breakout, options are h => hour, d => day, m => month.
|
51
|
+
+ **start_date** (string - Required): Inclusive start of the query in format yyyymmddhh00.
|
52
|
+
+ **end_date** (string - Required): Inclusive end of the query in format yyyymmddhh00.
|
53
|
+
+ **type** (string): Formatting type for the output, 'full' for one entry per row or 'ui' for a compressed, mapped version.
|
54
|
+
+ **order_by** (array): Ordered list of dimensions, metrics and/or 'date' indicating the order to return data.
|
55
|
+
+ **max_rows** (int): Max amount of rows to return back. If the result-set is larger than this max row size, the API will return an error message.
|
56
|
+
+ **limit** (int): Return the top-n dimension-sets matching the query where n is defined by this parameter. The sorting will be conducted over the total timeperiod, regardless of the time interval (hourly, daily, monthly) chosen. By default, the sorting will occur on the first selected metric, use {limit_by_metric} to change the sort ordering.
|
57
|
+
+ **limit_after_max** (int): Similar to limit, this value will cause the API to return the top-n rows matching the query if and only if the total rows without limiting would exceed the {max_rows} value (provided or default). Just like {limit}, the sorting will be conducted over the total timeperiod, regardless of the time interval (hourly, daily, monthly) chosen. By default, the sorting will occur on the first selected metric, use {limit_by_metric} to change the sort ordering.
|
58
|
+
+ **limit_by_metric** (string): Used in conjunction with {limit} to specify the metric to use in sorting the result set. If unset, the sorting will occur on the first selected metric.
|
59
|
+
+ **offset** (int): Used in conjunction with {limit} and {limit_by_metric} to specify the offset into the results. If unset, the offset is 0, returning the top {limit} results. The offset is 0-indexed, meaning an offset of 5 will ignore the first 5 results and return starting with the 6th. Useful for paging results.
|
60
|
+
+ **include_remainder** (bool): Used in conjunction with {limit}, {limit_by_metric} and {offset} to determine whether to compute and include a remainder or "Other" entry. If unset or 0, only the top {limit} results will be returned. If set to 1, an extra row will be appended with all the data past top {limit} results aggregated together. If an offset is specified, both the data before {offset} and after {offset} + {limit} will be included.
|
61
|
+
+ **include_dimension_lists** (bool): If set to true and type=full, the returned json will include a section entitled 'dimensionLists,' a map of dimension name to a list of all values for that dimension in the result set.
|
62
|
+
+ **include_zero_values** (bool): If set to true and type=full, every returned dimension-set will have a comlete array of values, including entries with metrics of 0 for timeperiods that do not include any data. If false, only the timeperiods and dimensions with data will be returned.
|
52
63
|
|
53
64
|
The `client.query` call will return a query object which can be executed with the method `get_result` or printed as
|
54
65
|
a the complete API url that will be executed with `get_url`.
|
55
66
|
|
56
67
|
###Example
|
57
|
-
From the user_info datamart
|
58
|
-
Select the hour, country and the total count of events
|
59
|
-
Where the country is either US, UK or CA and the event was between 2013/06/11 08:00 and 2013/06/11 09:00
|
60
|
-
Grouped by hour and country
|
68
|
+
From the user_info datamart
|
69
|
+
Select the hour, country and the total count of events
|
70
|
+
Where the country is either US, UK or CA and the event was between 2013/06/11 08:00 and 2013/06/11 09:00
|
71
|
+
Grouped by hour and country
|
61
72
|
|
62
73
|
require 'rubygems'
|
63
74
|
require 'grepdata_client'
|
@@ -77,6 +88,8 @@ Grouped by hour and country
|
|
77
88
|
req = client.query params
|
78
89
|
puts req.get_result
|
79
90
|
|
91
|
+
### Funneling Query
|
92
|
+
|
80
93
|
Funneling queries can also be issued from this client. Similar to querying above, the
|
81
94
|
client is configured with the api_key and fired with a set of query parameters:
|
82
95
|
+ **datamart** (string): the name of the datamart to query (endpoint name for timeseries data)
|
@@ -91,10 +104,10 @@ client is configured with the api_key and fired with a set of query parameters:
|
|
91
104
|
+ **only_totals** (boolean): a flag to indicate whether to collapse all data from the given timerange into a single total (true) or leave it broken out by time_interval (false)
|
92
105
|
|
93
106
|
###Example
|
94
|
-
From the demonstration datamart
|
95
|
-
Select the daily counts of play, pause, seek and stop events
|
96
|
-
Where the country is US and the events occurred between 2013/06/12 and 2013/06/19
|
97
|
-
Broken out by day and country
|
107
|
+
From the demonstration datamart
|
108
|
+
Select the daily counts of play, pause, seek and stop events
|
109
|
+
Where the country is US and the events occurred between 2013/06/12 and 2013/06/19
|
110
|
+
Broken out by day and country
|
98
111
|
|
99
112
|
require 'rubygems'
|
100
113
|
require 'grepdata_client'
|
@@ -109,7 +122,7 @@ Broken out by day and country
|
|
109
122
|
:dimensions => %w(event country),
|
110
123
|
:metrics => %w(Count),
|
111
124
|
:start_date => "201306120000",
|
112
|
-
:end_date => "201306190000",
|
125
|
+
:end_date => "201306190000",
|
113
126
|
:steps => [
|
114
127
|
{ :name => "step1: play", :value => "play" },
|
115
128
|
{ :name => "step2: pause", :value => "pause" },
|
@@ -49,9 +49,25 @@ module GrepdataClient
|
|
49
49
|
result[:datamart] = params[:datamart] if params[:datamart]
|
50
50
|
result[:metrics] = params[:metrics].join(',') if params[:metrics]
|
51
51
|
result[:dimensions] = params[:dimensions].join(',') if params[:dimensions]
|
52
|
+
result[:computed_dimensions] = params[:computed_dimensions] if params[:computed_dimensions]
|
52
53
|
result[:filters] = params[:filters].to_json if params[:filters]
|
53
54
|
result[:time_interval] = params[:time_interval] if params[:time_interval]
|
54
|
-
|
55
|
+
result[:type] = params[:type] if params[:type]
|
56
|
+
result[:order_by] = params[:order_by].join(',') if params[:order_by]
|
57
|
+
result[:max_rows] = params[:max_rows] if params[:max_rows]
|
58
|
+
result[:limit] = params[:limit] if params[:limit]
|
59
|
+
result[:limit_after_max] = params[:limit_after_max] if params[:limit_after_max]
|
60
|
+
result[:offset] = params[:offset] if params[:offset]
|
61
|
+
if params[:sortMetric]
|
62
|
+
limit_by_metric = params[:sortMetric]
|
63
|
+
elsif params[:limit_by_metric]
|
64
|
+
limit_by_metric = params[:limit_by_metric]
|
65
|
+
end
|
66
|
+
result[:limit_by_metric] = limit_by_metric if limit_by_metric
|
67
|
+
result[:include_remainder] = params[:include_remainder] if params[:include_remainder]
|
68
|
+
result[:include_dimension_lists] = params[:include_dimension_lists] if params[:include_dimension_lists]
|
69
|
+
result[:include_zero_values] = params[:include_zero_values] if params[:include_zero_values]
|
70
|
+
|
55
71
|
if action == "funneling"
|
56
72
|
steps = []
|
57
73
|
params[:steps].each do |step|
|
@@ -72,7 +88,8 @@ module GrepdataClient
|
|
72
88
|
result[:signature] = params[:signature] if params[:signature]
|
73
89
|
result[:restricted] = params[:restricted] if params[:restricted]
|
74
90
|
result[:expiration] = params[:expiration] if params[:expiration]
|
91
|
+
|
75
92
|
result
|
76
93
|
end
|
77
94
|
end
|
78
|
-
end
|
95
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grepdata_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typhoeus
|