@@ -30,12 +30,12 @@ def perform
3030
3131 def display_data_sovereignty_report
3232 # 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 )
3434 # 2. There is more than one distinct dataset schema (never ok for embedded dashboards where the expected schema num is only one)
3535
3636 puts "Data Sovereignty Report"
3737 puts "-----------------------"
38- puts "Possible Invalid Dashboards (CONFIRMATION REQUIRED) : #{ @data_sovereignty_issues . count } "
38+ puts "Possible Invalid Dashboards: #{ @data_sovereignty_issues . count } "
3939 @data_sovereignty_issues
4040 end
4141
@@ -54,7 +54,7 @@ def load_data_sovereignty_issues
5454 reasons << "DETAILS: #{ unknown_dataset_details ( unknown_datasets ) } "
5555 end
5656
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
5858 chart_dataset_schemas = dashboard [ :datasets ] [ :chart_datasets ] . map { |d | d [ :schema ] } . uniq
5959 if chart_dataset_schemas . count > 1
6060 reasons << "ERROR: Multiple distinct chart dataset schemas found. Expected 1. Found #{ chart_dataset_schemas . count } . " \
@@ -80,7 +80,6 @@ def create_dashboard_report
8080 @report ||= begin
8181 dashboard_ids . map do |dashboard_id |
8282 dashboard = dashboard_result ( dashboard_id )
83- # binding.pry
8483 {
8584 dashboard_id : dashboard_id ,
8685 dashboard_title : dashboard [ 'dashboard_title' ] ,
@@ -102,7 +101,7 @@ def filter_details(dashboard)
102101 end
103102
104103 def filter_count ( dashboard )
105- dashboard [ 'json_metadata' ] [ 'native_filter_configuration' ] . count
104+ dashboard [ 'json_metadata' ] [ 'native_filter_configuration' ] & .count || 0
106105 end
107106
108107 def filter_datasets ( dashboard )
@@ -116,7 +115,7 @@ def chart_count(dashboard)
116115 end
117116
118117 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
120119 {
121120 dataset_count : datasets . count ,
122121 chart_datasets : datasets
@@ -128,11 +127,11 @@ def dashboard_tags(dashboard)
128127 end
129128
130129 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
136135 end
137136 end
138137 end
0 commit comments