tembin 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/tembin/cli.rb +0 -4
- data/lib/tembin/redash.rb +0 -1
- data/lib/tembin/redash/client.rb +2 -3
- data/lib/tembin/redash/query.rb +27 -2
- data/lib/tembin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c63669bcb90b9c65de1839b08f22dcbc284e9406
|
4
|
+
data.tar.gz: 9995739c86196ff369e7ec2e8a166f943cb4f9c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38204adaff46a5e91e5d46fd0bd5df20578a63a9df4050231822f6c5758d51d6e23d887d9372f375622e0280cb29d27e06798ebe5f8d5e73a50cd184ea454129
|
7
|
+
data.tar.gz: f68ef8befa076ea997fd0b2f89adf0b4a4f19da0bec8026c4d66affadc9d6e12f912abf259151f99a6cfa5ff293d5ac7b2a27debdf5299206afa8ccbddce8023
|
data/README.md
CHANGED
data/lib/tembin/cli.rb
CHANGED
@@ -53,9 +53,5 @@ class Tembin::CLI < Thor
|
|
53
53
|
if Tembin::Redash.config['api_key'].nil?
|
54
54
|
raise ArgumentError, "Re:dash api key is empty. Please set Tembin::Redash.config['api_key']"
|
55
55
|
end
|
56
|
-
|
57
|
-
if Tembin::Redash.config['authorized_user_email'].nil?
|
58
|
-
raise ArgumentError, "Re:dash user login email is empty. Please set Tembin::Redash.config['authorized_user_email']"
|
59
|
-
end
|
60
56
|
end
|
61
57
|
end
|
data/lib/tembin/redash.rb
CHANGED
data/lib/tembin/redash/client.rb
CHANGED
@@ -5,12 +5,11 @@ module Tembin::Redash
|
|
5
5
|
class RequestNotSucceedError < StandardError; end
|
6
6
|
|
7
7
|
def self.current
|
8
|
-
Thread.current[:__tembin__redash_client__] ||= new(Tembin::Redash.config['api_key']
|
8
|
+
Thread.current[:__tembin__redash_client__] ||= new(Tembin::Redash.config['api_key'])
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize(api_key
|
11
|
+
def initialize(api_key)
|
12
12
|
@api_key = api_key
|
13
|
-
@authorized_user_email = authorized_user_email
|
14
13
|
end
|
15
14
|
|
16
15
|
def get(path, params: {})
|
data/lib/tembin/redash/query.rb
CHANGED
@@ -3,15 +3,40 @@ require 'diffy'
|
|
3
3
|
|
4
4
|
module Tembin::Redash
|
5
5
|
class Query
|
6
|
+
class RequestNotSucceedError < StandardError; end
|
7
|
+
|
6
8
|
def self.all
|
7
9
|
response = Tembin::Redash::Client.current.get('/api/queries')
|
8
10
|
raise RequestNotSucceedError, response.body if !response.success?
|
9
11
|
JSON.parse(response.body)['results'].map { |j| self.new(j) }
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
PAGE_OPTION = {
|
15
|
+
page: 1,
|
16
|
+
page_size: 5,
|
17
|
+
}.freeze
|
18
|
+
def self.created_by_me(fetch_all_page: true)
|
19
|
+
if !fetch_all_page
|
20
|
+
return request_my_query(PAGE_OPTION)['results'].map { |j| self.new(j) }
|
21
|
+
end
|
22
|
+
responses = []
|
23
|
+
response = request_my_query(PAGE_OPTION)
|
24
|
+
responses << response
|
25
|
+
while response['count'] > (response['page'] * response['page_size'])
|
26
|
+
response = request_my_query(page: response['page'] + 1, page_size: response['page_size'])
|
27
|
+
responses << response
|
28
|
+
end
|
29
|
+
responses.flat_map { |r| r['results'].map { |j| new(j) } }
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.request_my_query(page_option = {})
|
33
|
+
response = Tembin::Redash::Client.current.get('/api/queries/my', params: page_option)
|
34
|
+
if !response.success?
|
35
|
+
raise RequestNotSucceedError, response.body
|
36
|
+
end
|
37
|
+
JSON.parse(response.body)
|
14
38
|
end
|
39
|
+
private_class_method :request_my_query
|
15
40
|
|
16
41
|
INITIAL_DATA_SOURCE_ID = 1
|
17
42
|
def self.create(name, sql)
|
data/lib/tembin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tembin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takatoshi Maeda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|