Class: Superset::Chart::Get
Constant Summary
Constants inherited
from Request
Request::PAGE_SIZE
Instance Attribute Summary collapse
Attributes inherited from Request
#page_num
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Request
#query_params, #response, #superset_host
Methods included from Display
#display_headers, #headings, #list, #rows, #table, #title
Constructor Details
#initialize(id) ⇒ Get
Returns a new instance of Get.
7
8
9
|
# File 'lib/superset/chart/get.rb', line 7
def initialize(id)
@id = id
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5
6
7
|
# File 'lib/superset/chart/get.rb', line 5
def id
@id
end
|
Class Method Details
.call(id) ⇒ Object
11
12
13
|
# File 'lib/superset/chart/get.rb', line 11
def self.call(id)
self.new(id).list
end
|
Instance Method Details
#datasource_id ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/superset/chart/get.rb', line 24
def datasource_id
if result.first['query_context'].present? && JSON.parse(result.first['query_context'])['datasource'].present?
JSON.parse(result.first['query_context'])['datasource']['id']
elsif result.first['params'].present? && JSON.parse(result.first['params'])['datasource'].present?
JSON.parse(result.first['params'])['datasource'].match(/^\d+/)[0].to_i
end
end
|
#owner_ids ⇒ Object
32
33
34
|
# File 'lib/superset/chart/get.rb', line 32
def owner_ids
result.first['owners'].map{|o| o['id']}
end
|
#params ⇒ Object
36
37
38
|
# File 'lib/superset/chart/get.rb', line 36
def params
JSON.parse(result.first['params']) if result.first['params'].present?
end
|
15
16
17
18
|
# File 'lib/superset/chart/get.rb', line 15
def perform
response
self
end
|
#query_context ⇒ Object
40
41
42
|
# File 'lib/superset/chart/get.rb', line 40
def query_context
JSON.parse(result.first['query_context']) if result.first['query_context'].present?
end
|
#result ⇒ Object
20
21
22
|
# File 'lib/superset/chart/get.rb', line 20
def result
[ super ]
end
|