Class: Superset::Dashboard::List
- Defined in:
- lib/superset/dashboard/list.rb
Constant Summary
Constants inherited from Request
Instance Attribute Summary collapse
-
#ids_not_in ⇒ Object
readonly
Returns the value of attribute ids_not_in.
-
#include_filter_dataset_schemas ⇒ Object
readonly
Returns the value of attribute include_filter_dataset_schemas.
-
#tags_contain ⇒ Object
readonly
Returns the value of attribute tags_contain.
-
#tags_equal ⇒ Object
readonly
Returns the value of attribute tags_equal.
-
#title_contains ⇒ Object
readonly
Returns the value of attribute title_contains.
-
#title_equals ⇒ Object
readonly
Returns the value of attribute title_equals.
Attributes inherited from Request
Class Method Summary collapse
Instance Method Summary collapse
- #all ⇒ Object
- #ids ⇒ Object
-
#initialize(title_contains: '', title_equals: '', tags_contain: [], tags_equal: [], ids_not_in: [], include_filter_dataset_schemas: false, **kwargs) ⇒ List
constructor
A new instance of List.
- #response ⇒ Object
- #retrieve_embedded_details(id) ⇒ Object
- #retrieve_schemas(id) ⇒ Object
- #rows ⇒ Object
- #to_h ⇒ Object
Methods inherited from Request
#query_params, #result, #superset_host
Methods included from Superset::Display
#list, #result, #table, #title
Constructor Details
#initialize(title_contains: '', title_equals: '', tags_contain: [], tags_equal: [], ids_not_in: [], include_filter_dataset_schemas: false, **kwargs) ⇒ List
Returns a new instance of List.
12 13 14 15 16 17 18 19 20 |
# File 'lib/superset/dashboard/list.rb', line 12 def initialize(title_contains: '', title_equals: '', tags_contain: [], tags_equal: [], ids_not_in: [], include_filter_dataset_schemas: false, **kwargs) @title_contains = title_contains @title_equals = title_equals = = @ids_not_in = ids_not_in @include_filter_dataset_schemas = include_filter_dataset_schemas super(**kwargs) end |
Instance Attribute Details
#ids_not_in ⇒ Object (readonly)
Returns the value of attribute ids_not_in.
8 9 10 |
# File 'lib/superset/dashboard/list.rb', line 8 def ids_not_in @ids_not_in end |
#include_filter_dataset_schemas ⇒ Object (readonly)
Returns the value of attribute include_filter_dataset_schemas.
8 9 10 |
# File 'lib/superset/dashboard/list.rb', line 8 def include_filter_dataset_schemas @include_filter_dataset_schemas end |
#tags_contain ⇒ Object (readonly)
Returns the value of attribute tags_contain.
8 9 10 |
# File 'lib/superset/dashboard/list.rb', line 8 def end |
#tags_equal ⇒ Object (readonly)
Returns the value of attribute tags_equal.
8 9 10 |
# File 'lib/superset/dashboard/list.rb', line 8 def end |
#title_contains ⇒ Object (readonly)
Returns the value of attribute title_contains.
8 9 10 |
# File 'lib/superset/dashboard/list.rb', line 8 def title_contains @title_contains end |
#title_equals ⇒ Object (readonly)
Returns the value of attribute title_equals.
8 9 10 |
# File 'lib/superset/dashboard/list.rb', line 8 def title_equals @title_equals end |
Class Method Details
.call ⇒ Object
22 23 24 |
# File 'lib/superset/dashboard/list.rb', line 22 def self.call self.new.list end |
Instance Method Details
#all ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/superset/dashboard/list.rb', line 31 def all result.map do |d| OpenStruct.new( list_attributes.map { |la| [la, d[la]] }.to_h. merge(retrieve_schemas(d[:id])). merge((d[:id])) ) end end |
#ids ⇒ Object
71 72 73 |
# File 'lib/superset/dashboard/list.rb', line 71 def ids result.is_a?(Hash) ? [result[:id]] : result.map { |d| d[:id] } end |
#response ⇒ Object
26 27 28 29 |
# File 'lib/superset/dashboard/list.rb', line 26 def response validate_constructor_args super end |
#retrieve_embedded_details(id) ⇒ Object
49 50 51 52 53 |
# File 'lib/superset/dashboard/list.rb', line 49 def (id) = Dashboard::Embedded::Get.new(dashboard_id: id) { allowed_embedded_domains: .allowed_domains, uuid: .uuid,} end |
#retrieve_schemas(id) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/superset/dashboard/list.rb', line 41 def retrieve_schemas(id) { schemas: Datasets::List.new(dashboard_id: id, include_filter_datasets: include_filter_dataset_schemas).schemas } rescue StandardError => e # within Superset, a bug exists around deleting dashboards failing and the corrupting datasets configs, so handle errored datasets gracefully # ref NEP-17532 {} end |
#rows ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/superset/dashboard/list.rb', line 55 def rows result.map do |d| list_attributes.map do |la| la == :url ? "#{superset_host}#{d[la]}" : d[la] end end end |
#to_h ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/superset/dashboard/list.rb', line 63 def to_h result.map do |d| list_attributes.to_h do |la| la == :url ? [la, "#{superset_host}#{d[la]}"] : [la, d[la]] end end end |