Class: Superset::Dashboard::Datasets::List
- Defined in:
- lib/superset/dashboard/datasets/list.rb
Constant Summary
Constants inherited from Request
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
id - dashboard id.
-
#include_filter_datasets ⇒ Object
readonly
id - dashboard id.
Attributes inherited from Request
Class Method Summary collapse
Instance Method Summary collapse
- #datasets_details ⇒ Object
-
#initialize(dashboard_id:, include_filter_datasets: false) ⇒ List
constructor
A new instance of List.
- #perform ⇒ Object
- #schemas ⇒ Object
Methods inherited from Request
#query_params, #response, #result, #superset_host
Methods included from Superset::Display
#display_headers, #headings, #list, #result, #table
Constructor Details
#initialize(dashboard_id:, include_filter_datasets: false) ⇒ List
Returns a new instance of List.
16 17 18 19 |
# File 'lib/superset/dashboard/datasets/list.rb', line 16 def initialize(dashboard_id:, include_filter_datasets: false) @id = dashboard_id @include_filter_datasets = include_filter_datasets end |
Instance Attribute Details
#id ⇒ Object (readonly)
id - dashboard id
10 11 12 |
# File 'lib/superset/dashboard/datasets/list.rb', line 10 def id @id end |
#include_filter_datasets ⇒ Object (readonly)
id - dashboard id
10 11 12 |
# File 'lib/superset/dashboard/datasets/list.rb', line 10 def include_filter_datasets @include_filter_datasets end |
Class Method Details
.call(id) ⇒ Object
12 13 14 |
# File 'lib/superset/dashboard/datasets/list.rb', line 12 def self.call(id) self.new(id).list end |
Instance Method Details
#datasets_details ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/superset/dashboard/datasets/list.rb', line 39 def datasets_details chart_datasets = result.map do |details| details.slice('id', 'datasource_name', 'schema', 'sql').merge('database' => details['database'].slice('id', 'name', 'backend')).with_indifferent_access end return chart_datasets unless include_filter_datasets chart_dataset_ids = chart_datasets.map{|d| d['id'] } filter_dataset_ids_not_used_in_charts = filter_dataset_ids - chart_dataset_ids return chart_datasets if filter_dataset_ids_not_used_in_charts.empty? # returning chart and filter datasets chart_datasets + filter_datasets(filter_dataset_ids_not_used_in_charts) end |
#perform ⇒ Object
21 22 23 24 |
# File 'lib/superset/dashboard/datasets/list.rb', line 21 def perform response self end |
#schemas ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/superset/dashboard/datasets/list.rb', line 26 def schemas @schemas ||= begin all_dashboard_schemas = datasets_details.map {|d| d[:schema] }.uniq # For the current superset setup we will assume a dashboard datasets will point to EXACTLY one schema, their own. # if not .. we need to know about it. Potentially we could override this check if others do not consider it a problem. if all_dashboard_schemas.count > 1 Rollbar.error("SUPERSET DASHBOARD ERROR: Dashboard id #{id} has multiple dataset schema linked: #{all_dashboard_schemas.to_s}") end all_dashboard_schemas end end |