Class: Superset::Dashboard::List

Inherits:
Request
  • Object
show all
Defined in:
lib/superset/dashboard/list.rb

Constant Summary

Constants inherited from Request

Request::DEFAULT_PAGE_SIZE

Instance Attribute Summary collapse

Attributes inherited from Request

#page_num, #page_size

Class Method Summary collapse

Instance Method Summary collapse

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
  @tags_contain = tags_contain
  @tags_equal = tags_equal
  @ids_not_in = ids_not_in
  @include_filter_dataset_schemas = include_filter_dataset_schemas
  super(**kwargs)
end

Instance Attribute Details

#ids_not_inObject (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_schemasObject (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_containObject (readonly)

Returns the value of attribute tags_contain.



8
9
10
# File 'lib/superset/dashboard/list.rb', line 8

def tags_contain
  @tags_contain
end

#tags_equalObject (readonly)

Returns the value of attribute tags_equal.



8
9
10
# File 'lib/superset/dashboard/list.rb', line 8

def tags_equal
  @tags_equal
end

#title_containsObject (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_equalsObject (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

.callObject



22
23
24
# File 'lib/superset/dashboard/list.rb', line 22

def self.call
  self.new.list
end

Instance Method Details

#allObject



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(retrieve_embedded_details(d[:id]))
      )
  end
end

#idsObject



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

#responseObject



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 retrieve_embedded_details(id)
  embedded_dashboard = Dashboard::Embedded::Get.new(dashboard_id: id)
  { allowed_embedded_domains: embedded_dashboard.allowed_domains,
    uuid: embedded_dashboard.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

#rowsObject



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_hObject



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