Class: Superset::Dashboard::BulkDeleteCascade

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

Defined Under Namespace

Classes: InvalidParameterError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dashboard_ids: []) ⇒ BulkDeleteCascade

Returns a new instance of BulkDeleteCascade.



14
15
16
# File 'lib/superset/dashboard/bulk_delete_cascade.rb', line 14

def initialize(dashboard_ids: [])
  @dashboard_ids = dashboard_ids
end

Instance Attribute Details

#dashboard_idsObject (readonly)

Returns the value of attribute dashboard_ids.



12
13
14
# File 'lib/superset/dashboard/bulk_delete_cascade.rb', line 12

def dashboard_ids
  @dashboard_ids
end

Instance Method Details

#performObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/superset/dashboard/bulk_delete_cascade.rb', line 18

def perform
  raise InvalidParameterError, "dashboard_ids array of integers expected" unless dashboard_ids.is_a?(Array)
  raise InvalidParameterError, "dashboard_ids array must contain Integer only values" unless dashboard_ids.all? { |item| item.is_a?(Integer) }

  dashboard_ids.sort.each do |dashboard_id|
    logger.info("Dashboard Id: #{dashboard_id.to_s} Attempting CASCADE delete of dashboard, charts, datasets")
    delete_datasets(dashboard_id)
    delete_charts(dashboard_id)
    delete_dashboard(dashboard_id)
  end
  true
end