superset 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/lib/superset/dashboard/bulk_delete_cascade.rb +31 -12
- data/lib/superset/dashboard/export.rb +7 -18
- data/lib/superset/dashboard/import.rb +1 -1
- data/lib/superset/dataset/bulk_delete.rb +4 -3
- data/lib/superset/file_utilities.rb +5 -1
- data/lib/superset/services/import_dashboard_across_environment.rb +1 -1
- data/lib/superset/version.rb +1 -1
- data/superset.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a175ae90fbf33b12baafc49758b5c9b2e2869702a6be4f45849f66ac5a40afee
|
|
4
|
+
data.tar.gz: bc9938edda2fd5879b1f1824116b572638ea8685dd7b4115ca3fbfba08cf6a3f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 07d9b38d89bc252ea2a64b0cb835e9b9eefde88182636b4e8f900ccb7800e4e41f46fa3d15251ce3ba959f2805747f44b482d3b6b93c989ecbcb064d5d50ada9
|
|
7
|
+
data.tar.gz: 77a8f91b04674504ec174ba04e166b30fd5e42e30ce0c7b9a5904944893108fd5a5ef8052c066082d476c79518dacd911c3660d246e9b6bd9bf9f11fafe6c9f7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
##
|
|
1
|
+
## Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.6 - 2026-02-26
|
|
4
|
+
|
|
5
|
+
* add dry_run to dashboard bulk delete cascade #74
|
|
6
|
+
* update to rubyzip 3.2.2 #73
|
|
7
|
+
|
|
8
|
+
## 0.3.5 - 2026-02-24
|
|
9
|
+
|
|
10
|
+
* allow for empty filter datasets #72
|
|
11
|
+
|
|
12
|
+
## 0.3.4 - 2026-02-21
|
|
13
|
+
|
|
14
|
+
* cascade ownership should also update datasets for filter only in #68
|
|
15
|
+
* add owner filter #62
|
|
16
|
+
* list dataset catalog db names #69
|
|
17
|
+
* bump version to 0.3.4 #70
|
|
18
|
+
* Adjust asset order for board cascade deletion #71
|
|
2
19
|
|
|
3
20
|
## 0.3.3 - 2025-12-11
|
|
4
21
|
* Add databases method to Superset::Dashboard::Datasets::List
|
|
@@ -9,10 +9,11 @@ module Superset
|
|
|
9
9
|
class BulkDeleteCascade
|
|
10
10
|
class InvalidParameterError < StandardError; end
|
|
11
11
|
|
|
12
|
-
attr_reader :dashboard_ids
|
|
12
|
+
attr_reader :dashboard_ids, :dry_run
|
|
13
13
|
|
|
14
|
-
def initialize(dashboard_ids: [])
|
|
14
|
+
def initialize(dashboard_ids: [], dry_run: true)
|
|
15
15
|
@dashboard_ids = dashboard_ids
|
|
16
|
+
@dry_run = dry_run
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def perform
|
|
@@ -20,9 +21,16 @@ module Superset
|
|
|
20
21
|
raise InvalidParameterError, "dashboard_ids array must contain Integer only values" unless dashboard_ids.all? { |item| item.is_a?(Integer) }
|
|
21
22
|
|
|
22
23
|
dashboard_ids.sort.each do |dashboard_id|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
chart_ids = retrieve_chart_ids(dashboard_id)
|
|
25
|
+
dataset_ids = retrieve_dataset_ids(dashboard_id)
|
|
26
|
+
|
|
27
|
+
log_msg("------------------------- DRY RUN ONLY ---------------------------") if dry_run
|
|
28
|
+
log_msg("Dashboard Id: #{dashboard_id.to_s} Attempting CASCADE delete of dashboard, charts, datasets")
|
|
29
|
+
log_msg(" Charts: #{chart_ids.sort.join(', ')}")
|
|
30
|
+
log_msg(" Datasets: #{dataset_ids.sort.join(', ')}")
|
|
31
|
+
|
|
32
|
+
delete_charts(chart_ids)
|
|
33
|
+
delete_datasets(dataset_ids)
|
|
26
34
|
delete_dashboard(dashboard_id)
|
|
27
35
|
end
|
|
28
36
|
true
|
|
@@ -30,18 +38,29 @@ module Superset
|
|
|
30
38
|
|
|
31
39
|
private
|
|
32
40
|
|
|
33
|
-
def delete_datasets(
|
|
34
|
-
|
|
35
|
-
Superset::Dataset::BulkDelete.new(dataset_ids: datasets_to_delete).perform if datasets_to_delete.any?
|
|
41
|
+
def delete_datasets(dataset_ids)
|
|
42
|
+
Superset::Dataset::BulkDelete.new(dataset_ids: dataset_ids).perform if dataset_ids.any? && !dry_run
|
|
36
43
|
end
|
|
37
44
|
|
|
38
|
-
def delete_charts(
|
|
39
|
-
|
|
40
|
-
Superset::Chart::BulkDelete.new(chart_ids: charts_to_delete).perform if charts_to_delete.any?
|
|
45
|
+
def delete_charts(chart_ids)
|
|
46
|
+
Superset::Chart::BulkDelete.new(chart_ids: chart_ids).perform if chart_ids.any? && !dry_run
|
|
41
47
|
end
|
|
42
48
|
|
|
43
49
|
def delete_dashboard(dashboard_id)
|
|
44
|
-
Superset::Dashboard::Delete.new(dashboard_id: dashboard_id, confirm_zero_charts: true).perform
|
|
50
|
+
Superset::Dashboard::Delete.new(dashboard_id: dashboard_id, confirm_zero_charts: true).perform if !dry_run
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def retrieve_chart_ids(dashboard_id)
|
|
54
|
+
Superset::Dashboard::Charts::List.new(dashboard_id).chart_ids
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def retrieve_dataset_ids(dashboard_id)
|
|
58
|
+
Superset::Dashboard::Datasets::List.new(dashboard_id: dashboard_id).ids
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def log_msg(message)
|
|
62
|
+
puts message
|
|
63
|
+
logger.info(message)
|
|
45
64
|
end
|
|
46
65
|
|
|
47
66
|
def logger
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
# Will then unzip and copy the files into the destination_path with the dashboard_id as a subfolder
|
|
4
4
|
#
|
|
5
5
|
# Usage
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
=begin
|
|
7
|
+
Superset::Dashboard::Export.new(
|
|
8
|
+
dashboard_id: 15,
|
|
9
|
+
destination_path: '/superset_dashboard_backups/'
|
|
10
|
+
).perform
|
|
11
|
+
=end
|
|
8
12
|
|
|
9
13
|
require 'superset/file_utilities'
|
|
10
14
|
|
|
@@ -13,7 +17,7 @@ module Superset
|
|
|
13
17
|
class Export < Request
|
|
14
18
|
include FileUtilities
|
|
15
19
|
|
|
16
|
-
TMP_SUPERSET_DASHBOARD_PATH = '/tmp/superset_dashboard_exports'
|
|
20
|
+
TMP_SUPERSET_DASHBOARD_PATH = '/tmp/superset_dashboard_exports'.freeze
|
|
17
21
|
|
|
18
22
|
attr_reader :dashboard_id, :destination_path
|
|
19
23
|
|
|
@@ -125,21 +129,6 @@ module Superset
|
|
|
125
129
|
def datestamp
|
|
126
130
|
@datestamp ||= Time.now.strftime('%Y%m%d')
|
|
127
131
|
end
|
|
128
|
-
|
|
129
|
-
def unzip_file(zip_path, destination)
|
|
130
|
-
extracted_files = []
|
|
131
|
-
Zip::File.open(zip_path) do |zip_file|
|
|
132
|
-
zip_file.each do |entry|
|
|
133
|
-
entry_path = File.join(destination, entry.name)
|
|
134
|
-
FileUtils.mkdir_p(File.dirname(entry_path))
|
|
135
|
-
zip_file.extract(entry, entry_path) unless File.exist?(entry_path)
|
|
136
|
-
extracted_files << entry_path
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
extracted_files
|
|
140
|
-
rescue => e
|
|
141
|
-
raise
|
|
142
|
-
end
|
|
143
132
|
end
|
|
144
133
|
|
|
145
134
|
def logger
|
|
@@ -78,7 +78,7 @@ module Superset
|
|
|
78
78
|
def source_zip_file
|
|
79
79
|
return source if zip?
|
|
80
80
|
|
|
81
|
-
Zip::File.open(new_zip_file,
|
|
81
|
+
Zip::File.open(new_zip_file, create: true) do |zipfile|
|
|
82
82
|
Dir[File.join(source, "**", "**")].each do |file|
|
|
83
83
|
next unless File.file?(file)
|
|
84
84
|
|
|
@@ -16,10 +16,10 @@ module Superset
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def perform
|
|
19
|
-
raise InvalidParameterError, "dataset_ids array of integers expected" unless dataset_ids.is_a?(Array)
|
|
19
|
+
raise InvalidParameterError, "dataset_ids array of integers expected" unless dataset_ids.is_a?(Array) && dataset_ids.any?
|
|
20
20
|
raise InvalidParameterError, "dataset_ids array must contain Integer only values" unless dataset_ids.all? { |item| item.is_a?(Integer) }
|
|
21
21
|
|
|
22
|
-
logger.info("Deleting datasets with id: #{dataset_ids
|
|
22
|
+
logger.info("Deleting datasets with id: #{dataset_ids&.sort&.join(',')}")
|
|
23
23
|
response
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -30,7 +30,8 @@ module Superset
|
|
|
30
30
|
private
|
|
31
31
|
|
|
32
32
|
def params
|
|
33
|
-
|
|
33
|
+
dataset_ids_str = dataset_ids&.sort&.join(',')
|
|
34
|
+
{ q: "!(#{dataset_ids_str})" }
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def route
|
|
@@ -6,11 +6,15 @@ module Superset
|
|
|
6
6
|
entries = []
|
|
7
7
|
Zip::File.open(zip_file) do |zip|
|
|
8
8
|
zip.each do |entry|
|
|
9
|
+
next if entry.name.empty?
|
|
10
|
+
|
|
9
11
|
entry_path = File.join(destination, entry.name)
|
|
10
12
|
entries << entry_path
|
|
11
13
|
FileUtils.mkdir_p(File.dirname(entry_path))
|
|
12
14
|
|
|
13
|
-
zip.extract(entry,
|
|
15
|
+
zip.extract(entry, entry.name, destination_directory: destination) { true }
|
|
16
|
+
rescue => e
|
|
17
|
+
raise "Error extracting file #{entry.name}: #{e.message}"
|
|
14
18
|
end
|
|
15
19
|
end
|
|
16
20
|
|
|
@@ -87,7 +87,7 @@ module Superset
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
def create_new_dashboard_zip
|
|
90
|
-
Zip::File.open(new_zip_file,
|
|
90
|
+
Zip::File.open(new_zip_file, create: true) do |zipfile|
|
|
91
91
|
Dir[File.join(dashboard_export_root_path, '**', '**')].each do |file|
|
|
92
92
|
zipfile.add(file.sub(dashboard_export_root_path + '/', File.basename(dashboard_export_root_path) + '/' ), file) if File.file?(file)
|
|
93
93
|
end
|
data/lib/superset/version.rb
CHANGED
data/superset.gemspec
CHANGED
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
|
37
37
|
spec.add_dependency "json", ">= 2.0"
|
|
38
38
|
spec.add_dependency "terminal-table", "~> 4.0"
|
|
39
39
|
spec.add_dependency "require_all", ">= 3.0"
|
|
40
|
-
spec.add_dependency "rubyzip", ">=
|
|
40
|
+
spec.add_dependency "rubyzip", ">= 3.0"
|
|
41
41
|
spec.add_dependency "faraday", "~> 1.0"
|
|
42
42
|
spec.add_dependency "faraday-multipart", "~> 1.0"
|
|
43
43
|
spec.add_dependency "enumerate_it", ">= 1.7"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: superset
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jbat
|
|
@@ -57,14 +57,14 @@ dependencies:
|
|
|
57
57
|
requirements:
|
|
58
58
|
- - ">="
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
60
|
+
version: '3.0'
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
67
|
+
version: '3.0'
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: faraday
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|