Skip to content

Commit 9b09a90

Browse files
authored
Merge pull request #42 from rdytech/NEP-19106_fix_dashboard_embedding_issues
[NEP-19106]: Fix embedding logic in superset client
2 parents f3c6481 + 4d90676 commit 9b09a90

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## Change Log
22

3+
## 0.2.4 - 2025-01-29
4+
* modifies the `Superset::Dashboard::Datasets::List.new(id).schemas` to optionally include filter datasets as well.
5+
* modifies the `Superset::Dashboard::Embedded::Get.new` to accept dashboard_id as named parameter
6+
* modifies the `Superset::Dashboard::List.new()` to accept an additional named parameter `include_filter_dataset_schemas` to decide whether filter datasets needs to be included when getting the schemas of the datasets
7+
* modifies the `Superset::Dashboard::List.new().retrieve_schemas` to call `Datasets::List.new(dashboard_id: id).schemas` with an additional parameter `include_filter_datasets` to fetch the filter dataset schemas as well.
8+
9+
310
## 0.2.3 - 2024-11-15
411

512
* modifies the `Superset::Dashboard::Datasets::List.new(id).dataset_details` and `Superset::Dashboard::Datasets::List.new(id).list` to optionally include filter datasets as well to duplicate those during the dashboard duplication process. It also add a new column "Filter only" in the result which shows if a dataset is used only on filters

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ GIT
1414
PATH
1515
remote: .
1616
specs:
17-
superset (0.2.3)
17+
superset (0.2.4)
1818
dotenv (~> 2.7)
1919
enumerate_it (~> 1.7.0)
2020
faraday (~> 1.0)

lib/superset/dashboard/datasets/list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def perform
2525

2626
def schemas
2727
@schemas ||= begin
28-
all_dashboard_schemas = result.map {|d| d[:schema] }.uniq
28+
all_dashboard_schemas = datasets_details.map {|d| d[:schema] }.uniq
2929

3030
# For the current superset setup we will assume a dashboard datasets will point to EXACTLY one schema, their own.
3131
# if not .. we need to know about it. Potentially we could override this check if others do not consider it a problem.

lib/superset/dashboard/embedded/get.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def self.call(id)
88
self.new(id).list
99
end
1010

11-
def initialize(id)
12-
@id = id
11+
def initialize(dashboard_id:)
12+
@id = dashboard_id
1313
end
1414

1515
def response

lib/superset/dashboard/list.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
module Superset
66
module Dashboard
77
class List < Superset::Request
8-
attr_reader :title_contains, :title_equals, :tags_equal, :ids_not_in
8+
attr_reader :title_contains, :title_equals, :tags_equal, :ids_not_in, :include_filter_dataset_schemas
99

10-
def initialize(page_num: 0, title_contains: '', title_equals: '', tags_equal: [], ids_not_in: [])
10+
def initialize(page_num: 0, title_contains: '', title_equals: '', tags_equal: [], ids_not_in: [], include_filter_dataset_schemas: false)
1111
@title_contains = title_contains
1212
@title_equals = title_equals
1313
@tags_equal = tags_equal
1414
@ids_not_in = ids_not_in
15+
@include_filter_dataset_schemas = include_filter_dataset_schemas
1516
super(page_num: page_num)
1617
end
1718

@@ -35,15 +36,15 @@ def all
3536
end
3637

3738
def retrieve_schemas(id)
38-
{ schemas: Datasets::List.new(id).schemas }
39+
{ schemas: Datasets::List.new(dashboard_id: id, include_filter_datasets: include_filter_dataset_schemas).schemas }
3940
rescue StandardError => e
4041
# within Superset, a bug exists around deleting dashboards failing and the corrupting datasets configs, so handle errored datasets gracefully
4142
# ref NEP-17532
4243
{}
4344
end
4445

4546
def retrieve_embedded_details(id)
46-
embedded_dashboard = Dashboard::Embedded::Get.new(id)
47+
embedded_dashboard = Dashboard::Embedded::Get.new(dashboard_id: id)
4748
{ allowed_embedded_domains: embedded_dashboard.allowed_domains,
4849
uuid: embedded_dashboard.uuid,}
4950
end

lib/superset/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Superset
4-
VERSION = "0.2.3"
4+
VERSION = "0.2.4"
55
end

spec/superset/dashboard/embedded/get_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'spec_helper'
22

33
RSpec.describe Superset::Dashboard::Embedded::Get, type: :service do
4-
subject { described_class.new(dashboard_id) }
4+
subject { described_class.new(dashboard_id: dashboard_id) }
55
let(:dashboard_id) { 1 }
66

77
describe 'with a dashboard that has embedded settings, ie has a result' do

0 commit comments

Comments
 (0)