superset 0.3.3 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/superset/chart/list.rb +4 -2
- data/lib/superset/dashboard/bulk_delete_cascade.rb +1 -1
- data/lib/superset/dashboard/cascade_ownership/add_new_owner.rb +2 -2
- data/lib/superset/dashboard/datasets/list.rb +49 -38
- data/lib/superset/dashboard/list.rb +4 -2
- data/lib/superset/dataset/list.rb +5 -2
- data/lib/superset/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 565da0973df5cfd3aa9f1c555f477a9a9d710870c143ea2ca1678ff85febf3e6
|
|
4
|
+
data.tar.gz: 75620c8a9459443001e1b0ea62ccc5375f77d7bf5eb7b6bc6705bb840ed73b36
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 754a540a0a88322c7b63efce92ab04d44d3aaaebdd865f12ff7397414804e39a9e3a2586a6cfad0e26e0681fd556d22bc23b515ad69f7bc8ecdfd0a2f8aeb7b0
|
|
7
|
+
data.tar.gz: 4c1f810364a9389712183eabb06c81d473a634d8e6f6306d3b7b4b312818ad872df252f071f6b29df73cf622ebc3d0db37f009a0600a83358c464832a3f607c9
|
data/lib/superset/chart/list.rb
CHANGED
|
@@ -2,12 +2,13 @@ module Superset
|
|
|
2
2
|
module Chart
|
|
3
3
|
class List < Superset::Request
|
|
4
4
|
|
|
5
|
-
attr_reader :title_contains, :dashboard_id_eq, :dataset_id_eq
|
|
5
|
+
attr_reader :title_contains, :dashboard_id_eq, :dataset_id_eq, :owner_id_eq
|
|
6
6
|
|
|
7
|
-
def initialize(title_contains: '', dashboard_id_eq: '', dataset_id_eq: '', **kwargs)
|
|
7
|
+
def initialize(title_contains: '', dashboard_id_eq: '', dataset_id_eq: '', owner_id_eq: '', **kwargs)
|
|
8
8
|
@title_contains = title_contains
|
|
9
9
|
@dashboard_id_eq = dashboard_id_eq
|
|
10
10
|
@dataset_id_eq = dataset_id_eq
|
|
11
|
+
@owner_id_eq = owner_id_eq
|
|
11
12
|
super(**kwargs)
|
|
12
13
|
end
|
|
13
14
|
|
|
@@ -41,6 +42,7 @@ module Superset
|
|
|
41
42
|
filter_set << "(col:slice_name,opr:ct,value:'#{title_contains}')" if title_contains.present?
|
|
42
43
|
filter_set << "(col:dashboards,opr:rel_m_m,value:#{dashboard_id_eq})" if dashboard_id_eq.present? # rel many to many
|
|
43
44
|
filter_set << "(col:datasource_id,opr:eq,value:#{dataset_id_eq})" if dataset_id_eq.present?
|
|
45
|
+
filter_set << "(col:owners,opr:rel_m_m,value:#{owner_id_eq})" if owner_id_eq.present?
|
|
44
46
|
|
|
45
47
|
unless filter_set.empty?
|
|
46
48
|
"filters:!(" + filter_set.join(',') + "),"
|
|
@@ -21,8 +21,8 @@ module Superset
|
|
|
21
21
|
|
|
22
22
|
dashboard_ids.sort.each do |dashboard_id|
|
|
23
23
|
logger.info("Dashboard Id: #{dashboard_id.to_s} Attempting CASCADE delete of dashboard, charts, datasets")
|
|
24
|
-
delete_datasets(dashboard_id)
|
|
25
24
|
delete_charts(dashboard_id)
|
|
25
|
+
delete_datasets(dashboard_id)
|
|
26
26
|
delete_dashboard(dashboard_id)
|
|
27
27
|
end
|
|
28
28
|
true
|
|
@@ -36,7 +36,7 @@ module Superset
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def add_user_to_datasets_ownership
|
|
39
|
-
dataset_ids = Superset::Dashboard::Datasets::List.new(dashboard_id: dashboard_id).ids
|
|
39
|
+
dataset_ids = Superset::Dashboard::Datasets::List.new(dashboard_id: dashboard_id, include_filter_datasets: true).ids
|
|
40
40
|
dataset_ids.each do |dataset_id|
|
|
41
41
|
current_dataset_owner_ids = Superset::Dataset::Get.new(dataset_id).result['owners'].map{|c| c['id']}
|
|
42
42
|
next if current_dataset_owner_ids.include?(user_id)
|
|
@@ -51,4 +51,4 @@ module Superset
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
|
-
end
|
|
54
|
+
end
|
|
@@ -7,15 +7,12 @@ module Superset
|
|
|
7
7
|
module Dashboard
|
|
8
8
|
module Datasets
|
|
9
9
|
class List < Superset::Request
|
|
10
|
-
attr_reader :
|
|
10
|
+
attr_reader :dashboard_id, :include_filter_datasets, :include_catalog_lookup # id - dashboard id
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def initialize(dashboard_id:, include_filter_datasets: false)
|
|
17
|
-
@id = dashboard_id
|
|
12
|
+
def initialize(dashboard_id:, include_filter_datasets: false, include_catalog_lookup: false)
|
|
13
|
+
@dashboard_id = dashboard_id
|
|
18
14
|
@include_filter_datasets = include_filter_datasets
|
|
15
|
+
@include_catalog_lookup = include_catalog_lookup
|
|
19
16
|
end
|
|
20
17
|
|
|
21
18
|
def perform
|
|
@@ -23,33 +20,24 @@ module Superset
|
|
|
23
20
|
self
|
|
24
21
|
end
|
|
25
22
|
|
|
23
|
+
def datasets_details
|
|
24
|
+
@datasets_details ||= begin
|
|
25
|
+
datasets_list = chart_datasets + additional_filter_datasets
|
|
26
|
+
datasets_list = include_catalog_details(datasets_list) if include_catalog_lookup
|
|
27
|
+
datasets_list.compact
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
26
31
|
def databases
|
|
27
32
|
@databases ||= datasets_details.map {|d| d[:database] }.uniq
|
|
28
33
|
end
|
|
29
34
|
|
|
30
|
-
def
|
|
31
|
-
|
|
32
|
-
all_dashboard_schemas = datasets_details.map {|d| d[:schema] }.uniq
|
|
33
|
-
|
|
34
|
-
# For the current superset setup we will assume a dashboard datasets will point to EXACTLY one schema, their own.
|
|
35
|
-
# if not .. we need to know about it. Potentially we could override this check if others do not consider it a problem.
|
|
36
|
-
if all_dashboard_schemas.count > 1
|
|
37
|
-
Rollbar.error("SUPERSET DASHBOARD ERROR: Dashboard id #{id} has multiple dataset schema linked: #{all_dashboard_schemas.to_s}") if defined?(Rollbar)
|
|
38
|
-
end
|
|
39
|
-
all_dashboard_schemas
|
|
40
|
-
end
|
|
35
|
+
def catalogs
|
|
36
|
+
datasets_details.map {|d| d[:catalog] }.compact.uniq
|
|
41
37
|
end
|
|
42
38
|
|
|
43
|
-
def
|
|
44
|
-
|
|
45
|
-
details.slice('id', 'datasource_name', 'schema', 'sql').merge('database' => details['database'].slice('id', 'name', 'backend')).with_indifferent_access
|
|
46
|
-
end
|
|
47
|
-
return chart_datasets unless include_filter_datasets
|
|
48
|
-
chart_dataset_ids = chart_datasets.map{|d| d['id'] }
|
|
49
|
-
filter_dataset_ids_not_used_in_charts = filter_dataset_ids - chart_dataset_ids
|
|
50
|
-
return chart_datasets if filter_dataset_ids_not_used_in_charts.empty?
|
|
51
|
-
# returning chart and filter datasets
|
|
52
|
-
chart_datasets + filter_datasets(filter_dataset_ids_not_used_in_charts)
|
|
39
|
+
def schemas
|
|
40
|
+
datasets_details.map {|d| d[:schema] }.compact.uniq
|
|
53
41
|
end
|
|
54
42
|
|
|
55
43
|
def rows
|
|
@@ -68,24 +56,47 @@ module Superset
|
|
|
68
56
|
|
|
69
57
|
private
|
|
70
58
|
|
|
59
|
+
def include_catalog_details(datasets_list)
|
|
60
|
+
datasets_list.each {|d| d[:catalog] = Superset::Dataset::Get.new(d[:id].to_i).result['catalog'] }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# list of chart dataset details used in the dashboard
|
|
64
|
+
def chart_datasets
|
|
65
|
+
result.map do |details|
|
|
66
|
+
details.slice('id', 'datasource_name', 'schema', 'sql').merge('database' => details['database'].slice('id', 'name', 'backend')).with_indifferent_access
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# list of any additional filter dataset details on the dashboard that are not used in charts
|
|
71
|
+
def additional_filter_datasets
|
|
72
|
+
return [] unless include_filter_datasets
|
|
73
|
+
|
|
74
|
+
chart_dataset_ids = chart_datasets.map{|d| d['id'] }
|
|
75
|
+
filter_dataset_ids_not_used_in_charts = filter_dataset_ids - chart_dataset_ids
|
|
76
|
+
retrieve_filter_datasets(filter_dataset_ids_not_used_in_charts) unless filter_dataset_ids_not_used_in_charts.empty?
|
|
77
|
+
end
|
|
78
|
+
|
|
71
79
|
def filter_dataset_ids
|
|
72
80
|
@filter_dataset_ids ||= dashboard.filter_configuration.map { |c| c['targets'] }.flatten.compact.map { |c| c['datasetId'] }.flatten.compact.uniq
|
|
73
81
|
end
|
|
74
82
|
|
|
75
|
-
def
|
|
83
|
+
def retrieve_filter_datasets(filter_dataset_ids_not_used_in_charts)
|
|
76
84
|
filter_dataset_ids_not_used_in_charts.map do |filter_dataset_id|
|
|
77
85
|
filter_dataset = Superset::Dataset::Get.new(filter_dataset_id).result
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
{ id: filter_dataset_id,
|
|
87
|
+
datasource_name: filter_dataset['datasource_name'],
|
|
88
|
+
schema: filter_dataset['schema'],
|
|
89
|
+
sql: filter_dataset['sql'],
|
|
90
|
+
database: {
|
|
91
|
+
'id' => filter_dataset['database']['id'],
|
|
92
|
+
'name' => filter_dataset['database']['database_name'],
|
|
93
|
+
'backend' => filter_dataset['database']['backend'] },
|
|
94
|
+
filter_only: true }.with_indifferent_access
|
|
84
95
|
end
|
|
85
96
|
end
|
|
86
97
|
|
|
87
98
|
def route
|
|
88
|
-
"dashboard/#{
|
|
99
|
+
"dashboard/#{dashboard_id}/datasets"
|
|
89
100
|
end
|
|
90
101
|
|
|
91
102
|
def list_attributes
|
|
@@ -94,11 +105,11 @@ module Superset
|
|
|
94
105
|
|
|
95
106
|
# when displaying a list of datasets, show dashboard title as well
|
|
96
107
|
def title
|
|
97
|
-
@title ||= [
|
|
108
|
+
@title ||= [dashboard_id, dashboard.title].join(' ')
|
|
98
109
|
end
|
|
99
110
|
|
|
100
111
|
def dashboard
|
|
101
|
-
@dashboard ||= Superset::Dashboard::Get.new(
|
|
112
|
+
@dashboard ||= Superset::Dashboard::Get.new(dashboard_id)
|
|
102
113
|
end
|
|
103
114
|
end
|
|
104
115
|
end
|
|
@@ -7,14 +7,15 @@ module Superset
|
|
|
7
7
|
class List < Superset::Request
|
|
8
8
|
attr_reader :title_contains, :title_equals,
|
|
9
9
|
:tags_contain, :tags_equal,
|
|
10
|
-
:ids_not_in, :include_filter_dataset_schemas
|
|
10
|
+
:ids_not_in, :owner_id_eq, :include_filter_dataset_schemas
|
|
11
11
|
|
|
12
|
-
def initialize(title_contains: '', title_equals: '', tags_contain: [], tags_equal: [], ids_not_in: [], include_filter_dataset_schemas: false, **kwargs)
|
|
12
|
+
def initialize(title_contains: '', title_equals: '', tags_contain: [], tags_equal: [], ids_not_in: [], owner_id_eq: '', include_filter_dataset_schemas: false, **kwargs)
|
|
13
13
|
@title_contains = title_contains
|
|
14
14
|
@title_equals = title_equals
|
|
15
15
|
@tags_contain = tags_contain
|
|
16
16
|
@tags_equal = tags_equal
|
|
17
17
|
@ids_not_in = ids_not_in
|
|
18
|
+
@owner_id_eq = owner_id_eq
|
|
18
19
|
@include_filter_dataset_schemas = include_filter_dataset_schemas
|
|
19
20
|
super(**kwargs)
|
|
20
21
|
end
|
|
@@ -86,6 +87,7 @@ module Superset
|
|
|
86
87
|
filter_set << tags_contain_filters if tags_contain.present?
|
|
87
88
|
filter_set << tags_equal_filters if tags_equal.present?
|
|
88
89
|
filter_set << ids_not_in_filters if ids_not_in.present?
|
|
90
|
+
filter_set << "(col:owners,opr:rel_m_m,value:#{owner_id_eq})" if owner_id_eq.present?
|
|
89
91
|
|
|
90
92
|
unless filter_set.empty?
|
|
91
93
|
"filters:!(" + filter_set.join(',') + "),"
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
module Superset
|
|
2
2
|
module Dataset
|
|
3
3
|
class List < Superset::Request
|
|
4
|
-
attr_reader :title_contains, :title_equals, :schema_equals, :database_id_eq
|
|
4
|
+
attr_reader :title_contains, :title_equals, :schema_equals, :database_id_eq, :owner_id_eq
|
|
5
5
|
|
|
6
|
-
def initialize(title_contains: '', title_equals: '', schema_equals: '', database_id_eq: '', **kwargs)
|
|
6
|
+
def initialize(title_contains: '', title_equals: '', schema_equals: '', database_id_eq: '', owner_id_eq: '', **kwargs)
|
|
7
7
|
@title_contains = title_contains
|
|
8
8
|
@title_equals = title_equals
|
|
9
9
|
@schema_equals = schema_equals
|
|
10
10
|
@database_id_eq = database_id_eq
|
|
11
|
+
@owner_id_eq = owner_id_eq
|
|
11
12
|
super(**kwargs)
|
|
12
13
|
end
|
|
13
14
|
|
|
@@ -28,6 +29,8 @@ module Superset
|
|
|
28
29
|
filters << "(col:table_name,opr:eq,value:'#{title_equals}')" if title_equals.present?
|
|
29
30
|
filters << "(col:schema,opr:eq,value:'#{schema_equals}')" if schema_equals.present?
|
|
30
31
|
filters << "(col:database,opr:rel_o_m,value:#{database_id_eq})" if database_id_eq.present? # rel one to many
|
|
32
|
+
filters << "(col:owners,opr:rel_m_m,value:#{owner_id_eq})" if owner_id_eq.present?
|
|
33
|
+
|
|
31
34
|
unless filters.empty?
|
|
32
35
|
"filters:!(" + filters.join(',') + "),"
|
|
33
36
|
end
|
data/lib/superset/version.rb
CHANGED