Class: Superset::Dashboard::BulkDeleteCascade
- Inherits:
-
Object
- Object
- Superset::Dashboard::BulkDeleteCascade
- Defined in:
- lib/superset/dashboard/bulk_delete_cascade.rb
Defined Under Namespace
Classes: InvalidParameterError
Instance Attribute Summary collapse
-
#dashboard_ids ⇒ Object
readonly
Returns the value of attribute dashboard_ids.
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
Instance Method Summary collapse
-
#initialize(dashboard_ids: [], dry_run: true) ⇒ BulkDeleteCascade
constructor
A new instance of BulkDeleteCascade.
- #perform ⇒ Object
Constructor Details
#initialize(dashboard_ids: [], dry_run: true) ⇒ BulkDeleteCascade
Returns a new instance of BulkDeleteCascade.
14 15 16 17 |
# File 'lib/superset/dashboard/bulk_delete_cascade.rb', line 14 def initialize(dashboard_ids: [], dry_run: true) @dashboard_ids = dashboard_ids @dry_run = dry_run end |
Instance Attribute Details
#dashboard_ids ⇒ Object (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 |
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
12 13 14 |
# File 'lib/superset/dashboard/bulk_delete_cascade.rb', line 12 def dry_run @dry_run end |
Instance Method Details
#perform ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/superset/dashboard/bulk_delete_cascade.rb', line 19 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| chart_ids = retrieve_chart_ids(dashboard_id) dataset_ids = retrieve_dataset_ids(dashboard_id) log_msg("------------------------- DRY RUN ONLY ---------------------------") if dry_run log_msg("Dashboard Id: #{dashboard_id.to_s} Attempting CASCADE delete of dashboard, charts, datasets") log_msg(" Charts: #{chart_ids.sort.join(', ')}") log_msg(" Datasets: #{dataset_ids.sort.join(', ')}") delete_charts(chart_ids) delete_datasets(dataset_ids) delete_dashboard(dashboard_id) end true end |