Class: Superset::Dashboard::Export
- Includes:
- FileUtilities
- Defined in:
- lib/superset/dashboard/export.rb
Constant Summary collapse
- TMP_SUPERSET_DASHBOARD_PATH =
'/tmp/superset_dashboard_exports'
Constants inherited from Request
Instance Attribute Summary collapse
-
#dashboard_id ⇒ Object
readonly
Returns the value of attribute dashboard_id.
-
#destination_path ⇒ Object
readonly
Returns the value of attribute destination_path.
Attributes inherited from Request
Instance Method Summary collapse
-
#initialize(dashboard_id:, destination_path:) ⇒ Export
constructor
A new instance of Export.
- #perform ⇒ Object
- #response ⇒ Object
- #zip_file_name ⇒ Object
Methods inherited from Request
call, #query_params, #result, #superset_host
Methods included from Superset::Display
#display_headers, #headings, #list, #list_attributes, #result, #rows, #table, #title
Constructor Details
#initialize(dashboard_id:, destination_path:) ⇒ Export
Returns a new instance of Export.
20 21 22 23 |
# File 'lib/superset/dashboard/export.rb', line 20 def initialize(dashboard_id: , destination_path: ) @dashboard_id = dashboard_id @destination_path = destination_path.chomp('/') end |
Instance Attribute Details
#dashboard_id ⇒ Object (readonly)
Returns the value of attribute dashboard_id.
18 19 20 |
# File 'lib/superset/dashboard/export.rb', line 18 def dashboard_id @dashboard_id end |
#destination_path ⇒ Object (readonly)
Returns the value of attribute destination_path.
18 19 20 |
# File 'lib/superset/dashboard/export.rb', line 18 def destination_path @destination_path end |
Instance Method Details
#perform ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/superset/dashboard/export.rb', line 25 def perform logger.info("Exporting dashboard: #{dashboard_id}") create_tmp_dir save_exported_zip_file unzip_files clean_destination_directory copy_export_files_to_destination_path if destination_path Dir.glob("#{destination_path_with_dash_id}/**/*").select { |f| File.file?(f) } rescue StandardError => e raise ensure cleanup_temp_dir end |
#response ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/superset/dashboard/export.rb', line 40 def response @response ||= client.call( :get, client.url(route), client.param_check(params) ) end |
#zip_file_name ⇒ Object
48 49 50 |
# File 'lib/superset/dashboard/export.rb', line 48 def zip_file_name @zip_file_name ||= "#{tmp_uniq_dashboard_path}/dashboard_#{dashboard_id}_export_#{datestamp}.zip" end |