@@ -30,12 +30,12 @@ def perform
30
30
31
31
def display_data_sovereignty_report
32
32
# filter by dashboards where
33
- # 1. A filter dataset is not part of the dashboard datasets (might be ok for some cases)
33
+ # 1. A filter dataset is not part of the dashboard datasets (might be ok for some cases, ie a dummy dataset listing dates only )
34
34
# 2. There is more than one distinct dataset schema (never ok for embedded dashboards where the expected schema num is only one)
35
35
36
36
puts "Data Sovereignty Report"
37
37
puts "-----------------------"
38
- puts "Possible Invalid Dashboards (CONFIRMATION REQUIRED) : #{ @data_sovereignty_issues . count } "
38
+ puts "Possible Invalid Dashboards: #{ @data_sovereignty_issues . count } "
39
39
@data_sovereignty_issues
40
40
end
41
41
@@ -54,7 +54,7 @@ def load_data_sovereignty_issues
54
54
reasons << "DETAILS: #{ unknown_dataset_details ( unknown_datasets ) } "
55
55
end
56
56
57
- # add ERROR msg if multiple chart dataset schemas are found
57
+ # add ERROR msg if multiple chart dataset schemas are found, ie all datasets should be sourced from the same db schema
58
58
chart_dataset_schemas = dashboard [ :datasets ] [ :chart_datasets ] . map { |d | d [ :schema ] } . uniq
59
59
if chart_dataset_schemas . count > 1
60
60
reasons << "ERROR: Multiple distinct chart dataset schemas found. Expected 1. Found #{ chart_dataset_schemas . count } . " \
@@ -80,7 +80,6 @@ def create_dashboard_report
80
80
@report ||= begin
81
81
dashboard_ids . map do |dashboard_id |
82
82
dashboard = dashboard_result ( dashboard_id )
83
- # binding.pry
84
83
{
85
84
dashboard_id : dashboard_id ,
86
85
dashboard_title : dashboard [ 'dashboard_title' ] ,
@@ -102,7 +101,7 @@ def filter_details(dashboard)
102
101
end
103
102
104
103
def filter_count ( dashboard )
105
- dashboard [ 'json_metadata' ] [ 'native_filter_configuration' ] . count
104
+ dashboard [ 'json_metadata' ] [ 'native_filter_configuration' ] & .count || 0
106
105
end
107
106
108
107
def filter_datasets ( dashboard )
@@ -116,7 +115,7 @@ def chart_count(dashboard)
116
115
end
117
116
118
117
def dataset_details ( dashboard_id )
119
- datasets = Superset ::Dashboard ::Datasets ::List . new ( dashboard_id ) . rows_hash
118
+ datasets = Superset ::Dashboard ::Datasets ::List . new ( dashboard_id : dashboard_id ) . rows_hash
120
119
{
121
120
dataset_count : datasets . count ,
122
121
chart_datasets : datasets
@@ -128,11 +127,11 @@ def dashboard_tags(dashboard)
128
127
end
129
128
130
129
def dashboard_result ( dashboard_id )
131
- # convert json_metadata within result to a hash
132
- board = Superset ::Dashboard ::Get . new ( dashboard_id )
133
- board . result [ 'json_metadata' ] = JSON . parse ( board . result [ 'json_metadata' ] )
134
- board . result [ 'url' ] = board . url # add full url to the dashboard result
135
- board . result
130
+ # convert json_metadata within result to a hash
131
+ board = Superset ::Dashboard ::Get . new ( dashboard_id )
132
+ board . result [ 'json_metadata' ] = JSON . parse ( board . result [ 'json_metadata' ] )
133
+ board . result [ 'url' ] = board . url # add full url to the dashboard result
134
+ board . result
136
135
end
137
136
end
138
137
end
0 commit comments