You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2026/05/07 04:13:08 UTC

(superset) branch hughhhh/zagreb-embed-page updated: fix(dashboard): satisfy lint/format on Rison filter files

This is an automated email from the ASF dual-hosted git repository.

hughhhh pushed a commit to branch hughhhh/zagreb-embed-page
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/hughhhh/zagreb-embed-page by this push:
     new 4d001c7d9cb fix(dashboard): satisfy lint/format on Rison filter files
4d001c7d9cb is described below

commit 4d001c7d9cb3a637e435e3376a3b8315eaad1ba6
Author: Hugh A Miles II <hu...@gmail.com>
AuthorDate: Thu May 7 00:12:59 2026 -0400

    fix(dashboard): satisfy lint/format on Rison filter files
    
    - Move parseFilterCondition above parseRisonFilters to fix
      oxlint no-use-before-define
    - Apply prettier to risonFilters.ts and DashboardPage.tsx
    - Apply ruff-format to test_rison_filters.py
    
    Co-Authored-By: Claude Opus 4.7 <no...@anthropic.com>
---
 .../src/dashboard/containers/DashboardPage.tsx     |   6 +-
 .../src/dashboard/util/risonFilters.ts             | 130 +++++++++++----------
 tests/unit_tests/utils/test_rison_filters.py       |   1 -
 3 files changed, 71 insertions(+), 66 deletions(-)

diff --git a/superset-frontend/src/dashboard/containers/DashboardPage.tsx b/superset-frontend/src/dashboard/containers/DashboardPage.tsx
index c1f0c925cdd..30b2e25aae7 100644
--- a/superset-frontend/src/dashboard/containers/DashboardPage.tsx
+++ b/superset-frontend/src/dashboard/containers/DashboardPage.tsx
@@ -211,9 +211,9 @@ export const DashboardPage: FC<PageProps> = ({ idOrSlug }: PageProps) => {
         if (risonFilters.length > 0) {
           // Convert native filter config array to keyed object for lookup
           const filterConfigArray =
-            (dashboard?.metadata
-              ?.native_filter_configuration as Array<Record<string, unknown> & { id: string }>) ||
-            [];
+            (dashboard?.metadata?.native_filter_configuration as Array<
+              Record<string, unknown> & { id: string }
+            >) || [];
           const nativeFilters: PartialFilters = {};
           filterConfigArray.forEach(filter => {
             nativeFilters[filter.id] = filter as PartialFilters[string];
diff --git a/superset-frontend/src/dashboard/util/risonFilters.ts b/superset-frontend/src/dashboard/util/risonFilters.ts
index 2214dd80e6a..475b8bfdc7b 100644
--- a/superset-frontend/src/dashboard/util/risonFilters.ts
+++ b/superset-frontend/src/dashboard/util/risonFilters.ts
@@ -35,63 +35,6 @@ export interface IntelligentRisonInjectionResult {
   unmatchedFilters: RisonFilter[];
 }
 
-/**
- * Parse Rison filter syntax from URL parameter.
- * Supports formats like: (country:USA,year:2024)
- */
-export function parseRisonFilters(risonString: string): RisonFilter[] {
-  try {
-    const parsed = rison.decode(risonString);
-    const filters: RisonFilter[] = [];
-
-    if (!parsed || typeof parsed !== 'object') {
-      return filters;
-    }
-
-    const parsedObj = parsed as Record<string, unknown>;
-
-    // Handle OR operator: OR:!(condition1,condition2)
-    if (parsedObj.OR && Array.isArray(parsedObj.OR)) {
-      (parsedObj.OR as Record<string, unknown>[]).forEach(condition => {
-        if (typeof condition === 'object') {
-          Object.entries(condition).forEach(([key, value]) => {
-            filters.push(parseFilterCondition(key, value));
-          });
-        }
-      });
-      return filters;
-    }
-
-    // Handle NOT operator: NOT:(condition)
-    if (parsedObj.NOT && typeof parsedObj.NOT === 'object') {
-      Object.entries(parsedObj.NOT as Record<string, unknown>).forEach(
-        ([key, value]) => {
-          const filter = parseFilterCondition(key, value);
-          if (filter.operator === '==') {
-            filter.operator = '!=';
-          } else if (filter.operator === 'IN') {
-            filter.operator = 'NOT IN';
-          }
-          filters.push(filter);
-        },
-      );
-      return filters;
-    }
-
-    // Handle regular filters
-    Object.entries(parsedObj).forEach(([key, value]) => {
-      if (key !== 'OR' && key !== 'NOT') {
-        filters.push(parseFilterCondition(key, value));
-      }
-    });
-
-    return filters;
-  } catch (error) {
-    console.warn('Failed to parse Rison filters:', error);
-    return [];
-  }
-}
-
 /**
  * Parse individual filter condition
  */
@@ -165,6 +108,63 @@ function parseFilterCondition(key: string, value: unknown): RisonFilter {
   };
 }
 
+/**
+ * Parse Rison filter syntax from URL parameter.
+ * Supports formats like: (country:USA,year:2024)
+ */
+export function parseRisonFilters(risonString: string): RisonFilter[] {
+  try {
+    const parsed = rison.decode(risonString);
+    const filters: RisonFilter[] = [];
+
+    if (!parsed || typeof parsed !== 'object') {
+      return filters;
+    }
+
+    const parsedObj = parsed as Record<string, unknown>;
+
+    // Handle OR operator: OR:!(condition1,condition2)
+    if (parsedObj.OR && Array.isArray(parsedObj.OR)) {
+      (parsedObj.OR as Record<string, unknown>[]).forEach(condition => {
+        if (typeof condition === 'object') {
+          Object.entries(condition).forEach(([key, value]) => {
+            filters.push(parseFilterCondition(key, value));
+          });
+        }
+      });
+      return filters;
+    }
+
+    // Handle NOT operator: NOT:(condition)
+    if (parsedObj.NOT && typeof parsedObj.NOT === 'object') {
+      Object.entries(parsedObj.NOT as Record<string, unknown>).forEach(
+        ([key, value]) => {
+          const filter = parseFilterCondition(key, value);
+          if (filter.operator === '==') {
+            filter.operator = '!=';
+          } else if (filter.operator === 'IN') {
+            filter.operator = 'NOT IN';
+          }
+          filters.push(filter);
+        },
+      );
+      return filters;
+    }
+
+    // Handle regular filters
+    Object.entries(parsedObj).forEach(([key, value]) => {
+      if (key !== 'OR' && key !== 'NOT') {
+        filters.push(parseFilterCondition(key, value));
+      }
+    });
+
+    return filters;
+  } catch (error) {
+    console.warn('Failed to parse Rison filters:', error);
+    return [];
+  }
+}
+
 /**
  * Convert Rison filters to Superset adhoc filter format
  */
@@ -330,9 +330,7 @@ function findMatchingNativeFilter(
 
     const hasMatchingTarget = nativeFilter.targets.some(target => {
       if (typeof target === 'object' && target && 'column' in target) {
-        return (
-          target.column?.name?.trim().toLowerCase() === normalizedSubject
-        );
+        return target.column?.name?.trim().toLowerCase() === normalizedSubject;
       }
       return false;
     });
@@ -425,7 +423,11 @@ function convertRisonToNativeValue(
  */
 function buildDataMaskForFilter(
   risonFilter: RisonFilter,
-  nativeFilter: { id: string; filterType?: string; targets?: { column?: { name?: string } }[] },
+  nativeFilter: {
+    id: string;
+    filterType?: string;
+    targets?: { column?: { name?: string } }[];
+  },
   columnName: string,
 ) {
   const convertedValue = convertRisonToNativeValue(risonFilter, nativeFilter);
@@ -468,7 +470,11 @@ export function injectRisonFiltersIntelligently(
 
         const dataMaskEntry = buildDataMaskForFilter(
           risonFilter,
-          matchedFilter as { id: string; filterType?: string; targets?: { column?: { name?: string } }[] },
+          matchedFilter as {
+            id: string;
+            filterType?: string;
+            targets?: { column?: { name?: string } }[];
+          },
           columnName,
         );
 
diff --git a/tests/unit_tests/utils/test_rison_filters.py b/tests/unit_tests/utils/test_rison_filters.py
index ab30bd6ff60..4b3d6735d82 100644
--- a/tests/unit_tests/utils/test_rison_filters.py
+++ b/tests/unit_tests/utils/test_rison_filters.py
@@ -16,7 +16,6 @@
 # under the License.
 """Unit tests for Rison filter parser."""
 
-
 from superset.utils.rison_filters import RisonFilterParser