Skip to content

Commit 6f68d5b

Browse files
authored
Merge pull request #19 from SlicingDice/feature/change-tests-to-dimension
Change table to dimension on code
2 parents 6f896ae + f9d2549 commit 6f68d5b

5 files changed

Lines changed: 74 additions & 49 deletions

File tree

README.md

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ into the system, the answer should be a list whose only element is
3737
require 'rbslicer'
3838

3939
# Configure the client
40-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: true)
40+
client = SlicingDice.new(master_key: "API_KEY")
4141

4242
# Inserting data
4343
insert_data = {
4444
"user50@slicingdice.com" => {
4545
"age" => 22
4646
},
47-
"auto-create" => ["table", "column"]
47+
"auto-create" => ["dimension", "column"]
4848
}
4949
client.insert(insert_data)
5050

@@ -75,14 +75,13 @@ puts client.count_entity(query_data)
7575

7676
### Constructor
7777

78-
`initialize(master_key: nil, custom_key: nil, read_key: nil, write_key: nil, timeout: 60, use_ssl: true, uses_test_endpoint: false)`
78+
`initialize(master_key: nil, custom_key: nil, read_key: nil, write_key: nil, timeout: 60, use_ssl: true)`
7979
* `master_key (String)` - [API key](https://docs.slicingdice.com/docs/api-keys) to authenticate requests with the SlicingDice API.
8080
* `custom_key (String)` - [API key](https://docs.slicingdice.com/docs/api-keys) to authenticate requests with the SlicingDice API.
8181
* `read_key (String)` - [API key](https://docs.slicingdice.com/docs/api-keys) to authenticate requests with the SlicingDice API.
8282
* `write_key (String)` - [API key](https://docs.slicingdice.com/docs/api-keys) to authenticate requests with the SlicingDice API.
8383
* `use_ssl (Bool)` - Define if the requests verify SSL for HTTPS requests.
8484
* `timeout (Fixnum)` - Amount of time, in seconds, to wait for results for each request.
85-
* `uses_test_endpoint (Bool)` - If false the client will send requests to production end-point, otherwise to tests end-point.
8685

8786
### `get_database()`
8887
Get information about current database. This method corresponds to a `GET` request at `/database`.
@@ -91,7 +90,7 @@ Get information about current database. This method corresponds to a `GET` reque
9190

9291
```ruby
9392
require 'rbslicer'
94-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
93+
client = SlicingDice.new(master_key: "API_KEY")
9594

9695
puts client.get_database()
9796
```
@@ -102,7 +101,7 @@ puts client.get_database()
102101
{
103102
"name": "Database 1",
104103
"description": "My first database",
105-
"tables": [
104+
"dimensions": [
106105
"default",
107106
"users"
108107
],
@@ -118,7 +117,7 @@ Get all created columns, both active and inactive ones. This method corresponds
118117

119118
```ruby
120119
require 'rbslicer'
121-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
120+
client = SlicingDice.new(master_key: "API_KEY")
122121
puts client.get_columns()
123122
```
124123

@@ -157,7 +156,7 @@ Create a new column. This method corresponds to a [POST request at /column](http
157156

158157
```ruby
159158
require 'rbslicer'
160-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
159+
client = SlicingDice.new(master_key: "API_KEY")
161160
column = {
162161
"name" => "Year",
163162
"api-name" => "year",
@@ -184,7 +183,7 @@ Insert data to existing entities or create new entities, if necessary. This meth
184183

185184
```ruby
186185
require 'rbslicer'
187-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
186+
client = SlicingDice.new(master_key: "API_KEY")
188187
insert_data = {
189188
"user1@slicingdice.com" => {
190189
"car-model" => "Ford Ka",
@@ -218,7 +217,7 @@ insert_data = {
218217
"date" => "2016-08-17T13:23:47+00:00"
219218
}
220219
},
221-
"auto-create" => ["table", "column"]
220+
"auto-create" => ["dimension", "column"]
222221
}
223222
puts client.insert(insert_data)
224223
```
@@ -234,14 +233,14 @@ puts client.insert(insert_data)
234233
}
235234
```
236235

237-
### `exists_entity(ids, table)`
238-
Verify which entities exist in a table (uses `default` table if not provided) given a list of entity IDs. This method corresponds to a [POST request at /query/exists/entity](https://docs.slicingdice.com/docs/exists).
236+
### `exists_entity(ids, dimension)`
237+
Verify which entities exist in a dimension (uses `default` dimension if not provided) given a list of entity IDs. This method corresponds to a [POST request at /query/exists/entity](https://docs.slicingdice.com/docs/exists).
239238

240239
#### Request example
241240

242241
```ruby
243242
require 'rbslicer'
244-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
243+
client = SlicingDice.new(master_key: "API_KEY")
245244
ids = [
246245
"user1@slicingdice.com",
247246
"user2@slicingdice.com",
@@ -273,7 +272,7 @@ Count the number of inserted entities in the whole database. This method corresp
273272

274273
```ruby
275274
require 'rbslicer'
276-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
275+
client = SlicingDice.new(master_key: "API_KEY")
277276

278277
puts client.count_entity_total()
279278
```
@@ -290,18 +289,18 @@ puts client.count_entity_total()
290289
}
291290
```
292291

293-
### `count_entity_total(tables)`
294-
Count the total number of inserted entities in the given tables. This method corresponds to a [POST request at /query/count/entity/total](https://docs.slicingdice.com/docs/total#section-counting-specific-tables).
292+
### `count_entity_total(dimensions)`
293+
Count the total number of inserted entities in the given dimensions. This method corresponds to a [POST request at /query/count/entity/total](https://docs.slicingdice.com/docs/total#section-counting-specific-tables).
295294

296295
#### Request example
297296

298297
```ruby
299298
require 'rbslicer'
300-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
299+
client = SlicingDice.new(master_key: "API_KEY")
301300

302-
tables = ["default"]
301+
dimensions = ["default"]
303302

304-
puts client.count_entity_total(tables)
303+
puts client.count_entity_total(dimensions)
305304
```
306305

307306
#### Output example
@@ -323,7 +322,7 @@ Count the number of entities matching the given query. This method corresponds t
323322

324323
```ruby
325324
require 'rbslicer'
326-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
325+
client = SlicingDice.new(master_key: "API_KEY")
327326
query = [
328327
{
329328
'query-name' => 'corolla-or-fit',
@@ -377,7 +376,7 @@ Count the number of occurrences for time-series events matching the given query.
377376

378377
```ruby
379378
require 'rbslicer'
380-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
379+
client = SlicingDice.new(master_key: "API_KEY")
381380
query = [
382381
{
383382
'query-name' => 'test-drives-in-ny',
@@ -433,7 +432,7 @@ Return the top values for entities matching the given query. This method corresp
433432

434433
```ruby
435434
require 'rbslicer'
436-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
435+
client = SlicingDice.new(master_key: "API_KEY")
437436
query = {
438437
"car-year" => {
439438
"year" => 2
@@ -491,7 +490,7 @@ Return the aggregation of all columns in the given query. This method correspond
491490

492491
```ruby
493492
require 'rbslicer'
494-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
493+
client = SlicingDice.new(master_key: "API_KEY")
495494
query = {
496495
"query" => [
497496
{
@@ -543,7 +542,7 @@ Get all saved queries. This method corresponds to a [GET request at /query/saved
543542

544543
```ruby
545544
require 'rbslicer'
546-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
545+
client = SlicingDice.new(master_key: "API_KEY")
547546
puts client.get_saved_queries()
548547
```
549548

@@ -594,7 +593,7 @@ Create a saved query at SlicingDice. This method corresponds to a [POST request
594593

595594
```ruby
596595
require 'rbslicer'
597-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
596+
client = SlicingDice.new(master_key: "API_KEY")
598597
query = {
599598
"name" => "my-saved-query",
600599
"type" => "count/entity",
@@ -648,7 +647,7 @@ Update an existing saved query at SlicingDice. This method corresponds to a [PUT
648647

649648
```ruby
650649
require 'rbslicer'
651-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
650+
client = SlicingDice.new(master_key: "API_KEY")
652651
new_query = {
653652
"type" => "count/entity",
654653
"query" => [
@@ -700,7 +699,7 @@ Executed a saved query at SlicingDice. This method corresponds to a [GET request
700699

701700
```ruby
702701
require 'rbslicer'
703-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
702+
client = SlicingDice.new(master_key: "API_KEY")
704703
puts client.get_saved_query("my-saved-query")
705704
```
706705

@@ -737,7 +736,7 @@ Delete a saved query at SlicingDice. This method corresponds to a [DELETE reques
737736

738737
```ruby
739738
require 'rbslicer'
740-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
739+
client = SlicingDice.new(master_key: "API_KEY")
741740
puts client.delete_saved_query("my-saved-query")
742741
```
743742

@@ -774,7 +773,7 @@ Retrieve inserted values for entities matching the given query. This method corr
774773

775774
```ruby
776775
require 'rbslicer'
777-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
776+
client = SlicingDice.new(master_key: "API_KEY")
778777
query = {
779778
"query" => [
780779
{
@@ -823,7 +822,7 @@ Retrieve inserted values as well as their relevance for entities matching the gi
823822

824823
```ruby
825824
require 'rbslicer'
826-
client = SlicingDice.new(master_key: "API_KEY", uses_test_endpoint: false)
825+
client = SlicingDice.new(master_key: "API_KEY")
827826
query = {
828827
"query" => [
829828
{
@@ -868,6 +867,32 @@ puts client.score(query)
868867
}
869868
```
870869

870+
### `sql(query)`
871+
Retrieve inserted values using a SQL syntax. This method corresponds to a POST request at /query/sql.
872+
873+
#### Request example
874+
875+
```go
876+
require 'rbslicer'
877+
client = SlicingDice.new(master_key: "API_KEY")
878+
query = "SELECT COUNT(*) FROM default WHERE age BETWEEN 0 AND 49"
879+
880+
puts client.sql(query)
881+
```
882+
883+
#### Output example
884+
885+
```json
886+
{
887+
"took":0.063,
888+
"result":[
889+
{"COUNT": 3}
890+
],
891+
"count":1,
892+
"status":"success"
893+
}
894+
```
895+
871896
## License
872897

873898
[MIT](https://opensource.org/licenses/MIT)

lib/rbslicer.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ def count_entity(query)
197197

198198
# Public: Make a total query in SlicingDice API
199199
#
200-
# tables(Hash) - A Hash to send in request containing the tables in which
200+
# dimensions(Hash) - A Hash to send in request containing the dimensions in which
201201
# the total query will be performed
202202
#
203203
# Returns a count entity total query result
204-
def count_entity_total(tables=[])
204+
def count_entity_total(dimensions=[])
205205
url = @base_url + METHODS[:query_count_entity_total]
206206

207207
query = {
208-
"tables" => tables
208+
"dimensions" => dimensions
209209
}
210210

211211
make_request(url, "post", 0, data=query)
@@ -256,10 +256,10 @@ def top_values(query)
256256
# Public: Check if a list of entities exists in SlicingDice API
257257
#
258258
# ids(Array) - A Array with ids to be checked
259-
# table(String) - In which table entities check be checked
259+
# dimension(String) - In which dimension entities check be checked
260260
#
261261
# Returns a Hash with ids that exists and that don't exits
262-
def exists_entity(ids, table=nil)
262+
def exists_entity(ids, dimension=nil)
263263
url = @base_url + METHODS[:query_exists_entity]
264264
if ids.length > 100
265265
raise Exceptions::MaxLimitExceptions, 'The query exists entity must '\
@@ -268,8 +268,8 @@ def exists_entity(ids, table=nil)
268268
query = {
269269
'ids' => ids
270270
}
271-
if table.nil?
272-
query['table'] = table
271+
if dimension.nil?
272+
query['dimension'] = dimension
273273
end
274274
make_request(url, "post", 0, data=query)
275275
end

lib/rbslicer/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Rbslicer
2-
VERSION = '2.0.1'.freeze
2+
VERSION = '2.0.2'.freeze
33
end

tests_and_examples/examples/count_entity.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23283,7 +23283,7 @@
2328323283
"name": "Test for a \"COUNT ENTITY\" query using automatically created columns, operator \"AND\" and parameter \"EQUALS\".",
2328423284
"columns": [],
2328523285
"insert": {
23286-
"auto-create": ["table", "column"],
23286+
"auto-create": ["dimension", "column"],
2328723287
"24": {
2328823288
"string-test-column": "value:matched_value",
2328923289
"numeric-test-column": 1000001
@@ -23713,7 +23713,7 @@
2371323713
"name": "Test for a \"COUNT ENTITY\" query using automatically created columns, operators \"AND\" and \"OR\" and parameter \"EQUALS\".",
2371423714
"columns": [],
2371523715
"insert": {
23716-
"auto-create": ["table", "column"],
23716+
"auto-create": ["dimension", "column"],
2371723717
"24": {
2371823718
"string-test-column": "value:matched_value",
2371923719
"boolean-test-column": "true",
@@ -24251,7 +24251,7 @@
2425124251
"name": "Test for a \"COUNT ENTITY\" query using automatically created columns, operators \"AND\" and \"OR\" and parameters \"EQUALS\", \"BETWEEN\" and \"MINFREQ\".",
2425224252
"columns": [],
2425324253
"insert": {
24254-
"auto-create": ["table", "column"],
24254+
"auto-create": ["dimension", "column"],
2425524255
"24": {
2425624256
"string-test-column": "value:matched_value",
2425724257
"boolean-test-column": "true",

0 commit comments

Comments
 (0)