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_database_id ⇒ Object
readonly
Returns the value of attribute target_database_id.
-
#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:, allowed_domains: [], tags: [], publish: false) ⇒ 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
#display_headers, #headings, #list, #list_attributes, #result, #rows, #table, #title
Constructor Details
#initialize(source_dashboard_id:, target_schema:, target_database_id:, allowed_domains: [], tags: [], publish: false) ⇒ DuplicateDashboard
Returns a new instance of DuplicateDashboard.
14 15 16 17 18 19 20 21 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 14 def initialize(source_dashboard_id:, target_schema:, target_database_id: , allowed_domains: [], tags: [], publish: false) @source_dashboard_id = source_dashboard_id @target_schema = target_schema @target_database_id = target_database_id @allowed_domains = allowed_domains @tags = @publish = publish 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_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_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
61 62 63 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 61 def @new_dashboard_json_metadata_configuration ||= new_dashboard. end |
#perform ⇒ Object
23 24 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 |
# File 'lib/superset/services/duplicate_dashboard.rb', line 23 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.}") raise e end |