keen-cli 0.1.8 → 0.1.9

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.
data/README.md CHANGED
@@ -266,6 +266,7 @@ Parameters that apply to most commands include:
266
266
 
267
267
  ### Changelog
268
268
 
269
+ + 0.1.9 - Supports JSON-encoded filters and comma-seperated multiple group by
269
270
  + 0.1.8 - Inputted lines can also be arrays of JSON objects. `--batch-size` param is now properly recognized.
270
271
  + 0.1.7 - Add docs command
271
272
  + 0.1.6 - Big refactoring to make importing events much cleaner and batching happen automatically. Also adds `queries:url`.
@@ -106,15 +106,17 @@ module KeenCli
106
106
  end
107
107
 
108
108
  # copy query options in intelligently
109
- q_options[:group_by] = options[:"group-by"]
110
109
  q_options[:target_property] = options[:"target-property"]
111
110
  q_options[:interval] = options[:interval]
112
111
  q_options[:timeframe] = options[:timeframe]
113
- q_options[:filters] = options[:filters]
114
112
  q_options[:percentile] = options[:percentile]
115
113
  q_options[:latest] = options[:latest]
116
114
  q_options[:email] = options[:email]
117
115
 
116
+ if group_by = options[:"group-by"]
117
+ q_options[:group_by] = group_by.split(",")
118
+ end
119
+
118
120
  if property_names = options[:"property-names"]
119
121
  q_options[:property_names] = property_names.split(",")
120
122
  end
@@ -123,6 +125,10 @@ module KeenCli
123
125
  q_options[:timeframe] = { :start => start_time }
124
126
  end
125
127
 
128
+ if filters = options[:filters]
129
+ q_options[:filters] = JSON.parse(filters)
130
+ end
131
+
126
132
  if end_time = options[:end]
127
133
  q_options[:timeframe] = q_options[:timeframe] || {}
128
134
  q_options[:timeframe][:end] = end_time
@@ -1,3 +1,3 @@
1
1
  module KeenCli
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -96,6 +96,31 @@ module KeenCli
96
96
  })
97
97
  end
98
98
 
99
+ it 'deals with quoted csv values' do
100
+ batch_processor.csv = true
101
+ batch_processor.csv_options[:headers] = ['keen.timestamp', 'apple.date', 'apple.banana.cherry', 'apple.banana.walnut']
102
+ batch_processor.add('"2012-08-09, blah","blah pudding",smoothie,"b,u,tter"')
103
+ expect(batch_processor.events.first).to eq({
104
+ "apple" => {
105
+ "date" => "blah pudding",
106
+ "banana" => {
107
+ "cherry" => "smoothie",
108
+ "walnut" => "b,u,tter"
109
+ }
110
+ },
111
+ "keen" => {
112
+ "timestamp" => "2012-08-09, blah"
113
+ }
114
+ })
115
+
116
+ end
117
+
118
+ it 'deals with quoted csv headers' do
119
+ batch_processor.csv = true
120
+ batch_processor.add('"keen.timestamp","apple.date","apple.banana.cherry","apple.banana.walnut"')
121
+ expect(batch_processor.csv_options[:headers]).to eq(["keen.timestamp", "apple.date", "apple.banana.cherry", "apple.banana.walnut"])
122
+ end
123
+
99
124
  end
100
125
 
101
126
  describe 'add' do
@@ -23,12 +23,19 @@ describe KeenCli::CLI do
23
23
  end
24
24
 
25
25
  it 'converts dashes to underscores for certain properties' do
26
- url = "https://api.keen.io/3.0/projects/#{project_id}/queries/count?event_collection=minecraft-deaths&group_by=foo&target_property=bar"
26
+ url = "https://api.keen.io/3.0/projects/#{project_id}/queries/count?event_collection=minecraft-deaths&group_by=%5B%22foo%22%5D&target_property=bar"
27
27
  stub_request(:get, url).to_return(:body => { :result => 10 }.to_json)
28
28
  _, options = start 'queries:run --analysis-type count --collection minecraft-deaths --group-by foo --target-property bar'
29
29
  expect(_).to eq(10)
30
30
  end
31
31
 
32
+ it 'allows comma-delimited group by fields' do
33
+ url = "https://api.keen.io/3.0/projects/#{project_id}/queries/count?event_collection=minecraft-deaths&group_by=%5B%22%5C%22foo%22,%22bar%5C%22%22%5D&target_property=bar"
34
+ stub_request(:get, url).to_return(:body => { :result => 10 }.to_json)
35
+ _, options = start 'queries:run --analysis-type count --collection minecraft-deaths --group-by "foo,bar" --target-property bar'
36
+ expect(_).to eq(10)
37
+ end
38
+
32
39
  it 'accepts extraction-specific properties' do
33
40
  url = "https://api.keen.io/3.0/projects/#{project_id}/queries/extraction?event_collection=minecraft-deaths&property_names=%5B%22foo%22,%22bar%22%5D&latest=1&email=bob@bob.io"
34
41
  stub_request(:get, url).to_return(:body => { :result => 10 }.to_json)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keen-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
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: 2014-08-12 00:00:00.000000000 Z
12
+ date: 2014-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: keen