Class: Superset::Services::DuplicateDashboard
- Defined in:
- lib/superset/services/duplicate_dashboard.rb
Constant Summary
Constants inherited from Request
Instance Attribute Summary collapse
-
#allowed_domains ⇒ Object
readonly
Returns the value of attribute allowed_domains.
-
#publish ⇒ Object
readonly
Returns the value of attribute publish.
-
#source_dashboard_id ⇒ Object
readonly
Returns the value of attribute source_dashboard_id.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#target_catalog_name ⇒ Object
readonly
Returns the value of attribute target_catalog_name.
-
#target_database_id ⇒ Object
readonly
Returns the value of attribute target_database_id.
-
#target_dataset_suffix_override ⇒ Object
readonly
Returns the value of attribute target_dataset_suffix_override.
-
#target_schema ⇒ Object
readonly
Returns the value of attribute target_schema.
Attributes inherited from Request
Instance Method Summary collapse
-
#initialize(source_dashboard_id:, target_schema:, target_database_id:, target_dataset_suffix_override: nil, allowed_domains: [], tags: [], publish: false, target_catalog_name: nil) ⇒ DuplicateDashboard
constructor
A new instance of DuplicateDashboard.
- #new_dashboard_json_metadata_configuration ⇒ Object
- #perform ⇒ Object
Methods inherited from Request
call, #query_params, #response, #result, #superset_host
Methods included from Display
#ids, #list, #list_attributes, #result, #rows, #table, #title, #to_h
Constructor Details
#initialize(source_dashboard_id:, target_schema:, target_database_id:, target_dataset_suffix_override: nil, allowed_domains: [], tags: [], publish: false, target_catalog_name: nil) ⇒ DuplicateDashboard
Returns a new instance of DuplicateDashboard.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 14 def initialize(source_dashboard_id:, target_schema:, target_database_id: , target_dataset_suffix_override: nil, allowed_domains: [], tags: [], publish: false, target_catalog_name: nil) @source_dashboard_id = source_dashboard_id @target_schema = target_schema @target_database_id = target_database_id @target_dataset_suffix_override = target_dataset_suffix_override @allowed_domains = allowed_domains @tags = @publish = publish @target_catalog_name = target_catalog_name end |
Instance Attribute Details
#allowed_domains ⇒ Object (readonly)
Returns the value of attribute allowed_domains.
12 13 14 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 12 def allowed_domains @allowed_domains end |
#publish ⇒ Object (readonly)
Returns the value of attribute publish.
12 13 14 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 12 def publish @publish end |
#source_dashboard_id ⇒ Object (readonly)
Returns the value of attribute source_dashboard_id.
12 13 14 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 12 def source_dashboard_id @source_dashboard_id end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
12 13 14 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 12 def @tags end |
#target_catalog_name ⇒ Object (readonly)
Returns the value of attribute target_catalog_name.
12 13 14 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 12 def target_catalog_name @target_catalog_name end |
#target_database_id ⇒ Object (readonly)
Returns the value of attribute target_database_id.
12 13 14 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 12 def target_database_id @target_database_id end |
#target_dataset_suffix_override ⇒ Object (readonly)
Returns the value of attribute target_dataset_suffix_override.
12 13 14 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 12 def target_dataset_suffix_override @target_dataset_suffix_override end |
#target_schema ⇒ Object (readonly)
Returns the value of attribute target_schema.
12 13 14 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 12 def target_schema @target_schema end |
Instance Method Details
#new_dashboard_json_metadata_configuration ⇒ Object
68 69 70 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 68 def @new_dashboard_json_metadata_configuration ||= new_dashboard. end |
#perform ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 25 def perform # validate all params before starting the process validate_params # Pull the Datasets for all charts on the source dashboard source_dashboard_datasets # create a new_dashboard by copying the source_dashboard using with 'duplicate_slices: true' to get a new set of charts. # The new_dashboard will have a copy of charts from the source_dashboard, but with the same datasets as the source_dashboard new_dashboard # Duplicate these Datasets to the new target schema and target database duplicate_source_dashboard_datasets # Update the Charts on the New Dashboard with the New Datasets and update the Dashboard json_metadata for the charts update_charts_with_new_datasets # Duplicate filters to the new target schema and target database duplicate_source_dashboard_filters publish_dashboard if publish # return the new dashboard id and url { new_dashboard_id: new_dashboard.id, new_dashboard_url: new_dashboard.url, published: publish } rescue => e logger.error("#{e.}") remove_duplicated_objects puts "------------------------------------------------------------------------------\n" puts "DUPLICATE DASHBOARD FAILED - ERROR: #{e.}\n" puts "REMOVED DUPLICATED OBJECTS - Check log/superset-client.log for more details\n" puts "------------------------------------------------------------------------------\n" raise e end |