Class: Superset::Dashboard::List

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

Constant Summary

Constants inherited from Request

Request::PAGE_SIZE

Instance Attribute Summary collapse

Attributes inherited from Request

#page_num

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#query_params, #result, #superset_host

Methods included from Superset::Display

#display_headers, #headings, #list, #result, #table, #title

Constructor Details

#initialize(page_num: 0, title_contains: '', title_equals: '', tags_equal: [], ids_not_in: [], include_filter_dataset_schemas: false) ⇒ List

Returns a new instance of List.



10
11
12
13
14
15
16
17
# File 'lib/superset/dashboard/list.rb', line 10

def initialize(page_num: 0, title_contains: '', title_equals: '', tags_equal: [], ids_not_in: [], include_filter_dataset_schemas: false)
  @title_contains = title_contains
  @title_equals = title_equals
  @tags_equal = tags_equal
  @ids_not_in = ids_not_in
  @include_filter_dataset_schemas = include_filter_dataset_schemas
  super(page_num: page_num)
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_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



19
20
21
# File 'lib/superset/dashboard/list.rb', line 19

def self.call
  self.new.list
end

Instance Method Details

#allObject



28
29
30
31
32
33
34
35
36
# File 'lib/superset/dashboard/list.rb', line 28

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



60
61
62
# File 'lib/superset/dashboard/list.rb', line 60

def ids
  result.map { |d| d[:id] }
end

#responseObject



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

def response
  validate_constructor_args
  super
end

#retrieve_embedded_details(id) ⇒ Object



46
47
48
49
50
# File 'lib/superset/dashboard/list.rb', line 46

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



38
39
40
41
42
43
44
# File 'lib/superset/dashboard/list.rb', line 38

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



52
53
54
55
56
57
58
# File 'lib/superset/dashboard/list.rb', line 52

def rows
  result.map do |d|
    list_attributes.map do |la|
      la == :url ? "#{superset_host}#{d[la]}" : d[la]
    end
  end
end