File tree Expand file tree Collapse file tree 4 files changed +14
-33
lines changed Expand file tree Collapse file tree 4 files changed +14
-33
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,14 @@ module Superset
7
7
module Dashboard
8
8
module Datasets
9
9
class List < Superset ::Request
10
- attr_reader :id , :include_filter_datasets # dashboard id
10
+ attr_reader :id , :include_filter_datasets # id - dashboard id
11
11
12
12
def self . call ( id )
13
13
self . new ( id ) . list
14
14
end
15
15
16
- def initialize ( id , include_filter_datasets = false )
17
- @id = id
16
+ def initialize ( dashboard_id : , include_filter_datasets : false )
17
+ @id = dashboard_id
18
18
@include_filter_datasets = include_filter_datasets
19
19
end
20
20
@@ -50,7 +50,7 @@ def datasets_details
50
50
private
51
51
52
52
def filter_dataset_ids
53
- @filter_dataset_ids ||= Dashboard :: Filters :: List . new ( id ) . perform
53
+ @filter_dataset_ids ||= dashboard . filter_configuration . map { | c | c [ 'targets' ] } . flatten . compact . map { | c | c [ 'datasetId' ] } . flatten . compact
54
54
end
55
55
56
56
def filter_datasets ( filter_dataset_ids_not_used_in_charts )
@@ -88,7 +88,11 @@ def rows
88
88
89
89
# when displaying a list of datasets, show dashboard title as well
90
90
def title
91
- @title ||= [ id , Superset ::Dashboard ::Get . new ( id ) . title ] . join ( ' ' )
91
+ @title ||= [ id , dashboard . title ] . join ( ' ' )
92
+ end
93
+
94
+ def dashboard
95
+ @dashboard = Superset ::Dashboard ::Get . new ( id )
92
96
end
93
97
end
94
98
end
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ def title
25
25
def json_metadata
26
26
JSON . parse ( result [ 'json_metadata' ] )
27
27
end
28
+
29
+ def filter_configuration
30
+ json_metadata [ 'native_filter_configuration' ] || [ ]
31
+ end
28
32
29
33
def positions
30
34
JSON . parse ( result [ 'position_json' ] )
Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ def new_dashboard
183
183
184
184
# retrieve the datasets that will be duplicated
185
185
def source_dashboard_datasets
186
- @source_dashboard_datasets ||= Superset ::Dashboard ::Datasets ::List . new ( source_dashboard_id , true ) . datasets_details
186
+ @source_dashboard_datasets ||= Superset ::Dashboard ::Datasets ::List . new ( dashboard_id : source_dashboard_id , include_filter_datasets : true ) . datasets_details
187
187
rescue => e
188
188
raise "Unable to retrieve datasets for source dashboard #{ source_dashboard_id } : #{ e . message } "
189
189
end
You can’t perform that action at this time.
0 commit comments