keen-cli 0.1.3 → 0.1.4

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
@@ -141,7 +141,9 @@ Parameters:
141
141
  + `--analysis-type` (alias -a)
142
142
  + `--group-by` (alias -g)
143
143
  + `--target-property` (alias -y)
144
- + `--timeframe` (alias -t)
144
+ + `--timeframe` (alias -t) - A relative timeframe, e.g. `last_60_minutes`
145
+ + `--start` (alias -s) - The start time of an absolute timeframe
146
+ + `--end` (alias -e) - The end time of an absolute timeframe
145
147
  + `--interval` (alias -i)
146
148
  + `--filters` (alias -f)
147
149
  + `--percentile`
@@ -184,6 +186,10 @@ $ keen queries:run --collection cli-tests --analysis-type median --target-proper
184
186
  ...
185
187
  ...
186
188
 
189
+ # run a query with an absolute timeframe
190
+ $ keen queries:run --analysis-type count --start 2014-07-01T00:00:00Z --end 2014-07-31T23:59:59Z
191
+ 1000
192
+
187
193
  # run an extraction with specific property names
188
194
  $ keen queries:run --collection minecraft-deaths --analysis-type extraction --property-names player,enemy
189
195
  [
@@ -218,6 +224,7 @@ Run `keen` with no arguments to see the full list of aliases.
218
224
 
219
225
  ### Changelog
220
226
 
227
+ + 0.1.4 – Support absolute timeframes via `--start` and `--end` flags
221
228
  + 0.1.3 – Add querying via JSON. Add query aliases. Add support for extraction fields.
222
229
  + 0.1.2 – Change `project:show` to `project:describe`
223
230
  + 0.1.1 – Add `project:collections`
data/lib/keen-cli/cli.rb CHANGED
@@ -35,6 +35,8 @@ module KeenCli
35
35
  option :"property-names"
36
36
  option :latest
37
37
  option :email
38
+ option :start, :aliases => ['s']
39
+ option :end, :aliases => ['e']
38
40
  end
39
41
 
40
42
  desc 'version', 'Print the keen-cli version'
@@ -142,6 +144,15 @@ module KeenCli
142
144
  q_options[:property_names] = property_names.split(",")
143
145
  end
144
146
 
147
+ if start_time = q_options.delete("start")
148
+ q_options[:timeframe] = { :start => start_time }
149
+ end
150
+
151
+ if end_time = q_options.delete("end")
152
+ q_options[:timeframe] = q_options[:timeframe] || {}
153
+ q_options[:timeframe][:end] = end_time
154
+ end
155
+
145
156
  raise "No analysis type given!" unless analysis_type
146
157
  raise "No collection given!" unless collection
147
158
 
@@ -1,3 +1,3 @@
1
1
  module KeenCli
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -103,6 +103,28 @@ describe KeenCli::CLI do
103
103
  _, options = start 'queries:run --analysis-type count --data {"event_collection":"minecraft-deaths"}'
104
104
  expect(_).to eq(10)
105
105
  end
106
+
107
+ it 'converts a start parameter into an absolute timeframe' do
108
+ url = "https://api.keen.io/3.0/projects/#{project_id}/queries/count?event_collection=minecraft-deaths&timeframe=%7B%22start%22:%222014-07-06T12:00:00Z%22%7D"
109
+ stub_request(:get, url).to_return(:body => { :result => 10 }.to_json)
110
+ _, options = start 'queries:run --collection minecraft-deaths --analysis-type count --start 2014-07-06T12:00:00Z'
111
+ expect(_).to eq(10)
112
+ end
113
+
114
+ it 'converts an end parameter into an absolute timeframe' do
115
+ url = "https://api.keen.io/3.0/projects/#{project_id}/queries/count?event_collection=minecraft-deaths&timeframe=%7B%22end%22:%222014-07-06T12:00:00Z%22%7D"
116
+ stub_request(:get, url).to_return(:body => { :result => 10 }.to_json)
117
+ _, options = start 'queries:run --collection minecraft-deaths --analysis-type count --end 2014-07-06T12:00:00Z'
118
+ expect(_).to eq(10)
119
+ end
120
+
121
+ it 'converts start and end parameters into an absolute timeframe' do
122
+ url = "https://api.keen.io/3.0/projects/#{project_id}/queries/count?event_collection=minecraft-deaths&timeframe=%7B%22start%22:%222014-07-06T12:00:00Z%22,%22end%22:%222014-07-08T12:00:00Z%22%7D"
123
+ stub_request(:get, url).to_return(:body => { :result => 10 }.to_json)
124
+ _, options = start 'queries:run --collection minecraft-deaths --analysis-type count --start 2014-07-06T12:00:00Z --end 2014-07-08T12:00:00Z'
125
+ expect(_).to eq(10)
126
+ end
127
+
106
128
  end
107
129
 
108
130
  describe "queries:run aliases" do
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.3
4
+ version: 0.1.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: 2014-07-06 00:00:00.000000000 Z
12
+ date: 2014-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: keen
@@ -172,3 +172,4 @@ summary: Command line interface to Keen IO
172
172
  test_files:
173
173
  - spec/keen-cli/cli_spec.rb
174
174
  - spec/spec_helper.rb
175
+ has_rdoc: