Skip to content

Commit 864b931

Browse files
authored
Merge pull request #33 from rdytech/NEP-17878-add-dasboard-filter-title-equals
NEP-17878 add title equals filter for dashboard listing
2 parents 308d159 + 5a4ec83 commit 864b931

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

CHANGELOG.md

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

3+
## 0.1.7 - 2024-08-27
4+
5+
* adds filter title_equals to dashboard list class - https://github.com/rdytech/superset-client/pull/33
6+
37
## 0.1.6 - 2024-07-10
48

59
* added a class **WarmUpCache** to hit the 'api/v1/dataset/warm_up_cache' endpoint to warm up the cache of all the datasets for a particular dashaboard being passed to the class - https://github.com/rdytech/superset-client/pull/28

lib/superset/dashboard/list.rb

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

10-
def initialize(page_num: 0, title_contains: '', tags_equal: [], ids_not_in: [])
10+
def initialize(page_num: 0, title_contains: '', title_equals: '', tags_equal: [], ids_not_in: [])
1111
@title_contains = title_contains
12+
@title_equals = title_equals
1213
@tags_equal = tags_equal
1314
@ids_not_in = ids_not_in
1415
super(page_num: page_num)
@@ -69,6 +70,7 @@ def filters
6970
# TODO filtering across all list classes can be refactored to support multiple options in a more flexible way
7071
filter_set = []
7172
filter_set << "(col:dashboard_title,opr:ct,value:'#{title_contains}')" if title_contains.present?
73+
filter_set << "(col:dashboard_title,opr:eq,value:'#{title_equals}')" if title_equals.present?
7274
filter_set << tag_filters if tags_equal.present?
7375
filter_set << ids_not_in_filters if ids_not_in.present?
7476
unless filter_set.empty?
@@ -90,6 +92,7 @@ def list_attributes
9092

9193
def validate_constructor_args
9294
raise InvalidParameterError, "title_contains must be a String type" unless title_contains.is_a?(String)
95+
raise InvalidParameterError, "title_equals must be a String type" unless title_equals.is_a?(String)
9396
raise InvalidParameterError, "tags_equal must be an Array type" unless tags_equal.is_a?(Array)
9497
raise InvalidParameterError, "tags_equal array must contain string only values" unless tags_equal.all? { |item| item.is_a?(String) }
9598
raise InvalidParameterError, "ids_not_in must be an Array type" unless ids_not_in.is_a?(Array)

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.1.6"
4+
VERSION = "0.1.7"
55
end

spec/superset/dashboard/list_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@
9696
end
9797

9898
context 'with multiple filter set and multiple tags' do
99-
subject { described_class.new(page_num: 3, title_contains: 'birth', tags_equal: ['template', 'client:acme', 'product:turbo-charged-feet']) }
99+
subject { described_class.new(page_num: 3, title_contains: 'birth', title_equals: 'births in aust', tags_equal: ['template', 'client:acme', 'product:turbo-charged-feet']) }
100100

101101
specify do
102102
expect(subject.query_params).to eq(
103103
"filters:!(" \
104104
"(col:dashboard_title,opr:ct,value:'birth')," \
105+
"(col:dashboard_title,opr:eq,value:'births in aust')," \
105106
"(col:tags,opr:dashboard_tags,value:'template')," \
106107
"(col:tags,opr:dashboard_tags,value:'client:acme')," \
107108
"(col:tags,opr:dashboard_tags,value:'product:turbo-charged-feet')" \

0 commit comments

Comments
 (0)