From 7d315467882db2b5d111dfbfb76ddda3c317d79a Mon Sep 17 00:00:00 2001 From: jbat Date: Tue, 27 Aug 2024 08:09:35 +1000 Subject: [PATCH 1/2] NEP-17878 add title equals filter for dashboard listing --- lib/superset/dashboard/list.rb | 7 +++++-- spec/superset/dashboard/list_spec.rb | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/superset/dashboard/list.rb b/lib/superset/dashboard/list.rb index 1b54fc6..4519219 100644 --- a/lib/superset/dashboard/list.rb +++ b/lib/superset/dashboard/list.rb @@ -5,10 +5,11 @@ module Superset module Dashboard class List < Superset::Request - attr_reader :title_contains, :tags_equal, :ids_not_in + attr_reader :title_contains, :title_equals, :tags_equal, :ids_not_in - def initialize(page_num: 0, title_contains: '', tags_equal: [], ids_not_in: []) + def initialize(page_num: 0, title_contains: '', title_equals: '', tags_equal: [], ids_not_in: []) @title_contains = title_contains + @title_equals = title_equals @tags_equal = tags_equal @ids_not_in = ids_not_in super(page_num: page_num) @@ -69,6 +70,7 @@ def filters # TODO filtering across all list classes can be refactored to support multiple options in a more flexible way filter_set = [] filter_set << "(col:dashboard_title,opr:ct,value:'#{title_contains}')" if title_contains.present? + filter_set << "(col:dashboard_title,opr:eq,value:'#{title_equals}')" if title_equals.present? filter_set << tag_filters if tags_equal.present? filter_set << ids_not_in_filters if ids_not_in.present? unless filter_set.empty? @@ -90,6 +92,7 @@ def list_attributes def validate_constructor_args raise InvalidParameterError, "title_contains must be a String type" unless title_contains.is_a?(String) + raise InvalidParameterError, "title_equals must be a String type" unless title_equals.is_a?(String) raise InvalidParameterError, "tags_equal must be an Array type" unless tags_equal.is_a?(Array) raise InvalidParameterError, "tags_equal array must contain string only values" unless tags_equal.all? { |item| item.is_a?(String) } raise InvalidParameterError, "ids_not_in must be an Array type" unless ids_not_in.is_a?(Array) diff --git a/spec/superset/dashboard/list_spec.rb b/spec/superset/dashboard/list_spec.rb index 587c925..13dffca 100644 --- a/spec/superset/dashboard/list_spec.rb +++ b/spec/superset/dashboard/list_spec.rb @@ -96,12 +96,13 @@ end context 'with multiple filter set and multiple tags' do - subject { described_class.new(page_num: 3, title_contains: 'birth', tags_equal: ['template', 'client:acme', 'product:turbo-charged-feet']) } + subject { described_class.new(page_num: 3, title_contains: 'birth', title_equals: 'births in aust', tags_equal: ['template', 'client:acme', 'product:turbo-charged-feet']) } specify do expect(subject.query_params).to eq( "filters:!(" \ "(col:dashboard_title,opr:ct,value:'birth')," \ + "(col:dashboard_title,opr:eq,value:'births in aust')," \ "(col:tags,opr:dashboard_tags,value:'template')," \ "(col:tags,opr:dashboard_tags,value:'client:acme')," \ "(col:tags,opr:dashboard_tags,value:'product:turbo-charged-feet')" \ From 5a4ec838a1445a856eddea1784f2deb4c5cba86d Mon Sep 17 00:00:00 2001 From: jbat Date: Tue, 27 Aug 2024 08:36:01 +1000 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 4 ++++ lib/superset/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f307a8c..ae155e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Change Log +## 0.1.7 - 2024-08-27 + +* adds filter title_equals to dashboard list class - https://github.com/rdytech/superset-client/pull/33 + ## 0.1.6 - 2024-07-10 * 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 diff --git a/lib/superset/version.rb b/lib/superset/version.rb index 449c958..a010569 100644 --- a/lib/superset/version.rb +++ b/lib/superset/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Superset - VERSION = "0.1.6" + VERSION = "0.1.7" end