amaannawab923 commented on code in PR #35343:
URL: https://github.com/apache/superset/pull/35343#discussion_r2459721705


##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/stateConversion.ts:
##########
@@ -0,0 +1,194 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {
+  BackendOwnState,
+  QueryFilterClause,
+  QuerySortBy,
+  type AgGridChartState,
+  type AgGridSortModel,
+  type AgGridFilterModel,
+} from '@superset-ui/core';
+
+/**
+ * AG Grid text filter type to backend operator mapping
+ */
+const TEXT_FILTER_OPERATORS: Record<string, string> = {
+  equals: '==',
+  notEqual: '!=',
+  contains: 'ILIKE',
+  notContains: 'NOT ILIKE',
+  startsWith: 'ILIKE',
+  endsWith: 'ILIKE',
+};
+
+/**
+ * AG Grid number filter type to backend operator mapping
+ */
+const NUMBER_FILTER_OPERATORS: Record<string, string> = {
+  equals: '==',
+  notEqual: '!=',
+  lessThan: '<',
+  lessThanOrEqual: '<=',
+  greaterThan: '>',
+  greaterThanOrEqual: '>=',
+};
+
+/**
+ * Converts text filter value based on filter type
+ */
+function getTextComparator(type: string, value: string): string {
+  if (type === 'contains' || type === 'notContains') {
+    return `%${value}%`;
+  }
+  if (type === 'startsWith') {
+    return `${value}%`;
+  }
+  if (type === 'endsWith') {
+    return `%${value}`;
+  }
+  return value;
+}
+
+/**
+ * Converts AG Grid sortModel to backend sortBy format
+ */
+export function convertSortModel(
+  sortModel: AgGridSortModel[],
+): QuerySortBy[] | undefined {
+  if (!sortModel || sortModel.length === 0) {
+    return undefined;
+  }
+
+  const sortItem = sortModel[0];
+  return [
+    {
+      id: sortItem.colId,
+      key: sortItem.colId,
+      desc: sortItem.sort === 'desc',
+    },
+  ];
+}
+
+/**
+ * Extracts column order from AG Grid columnState
+ */
+export function convertColumnState(
+  columnState: Array<{ colId: string }>,
+): string[] | undefined {
+  if (!columnState || columnState.length === 0) {
+    return undefined;
+  }
+
+  return columnState.map(col => col.colId);
+}
+
+/**
+ * Converts AG Grid filterModel to backend filter clauses
+ */
+export function convertFilterModel(
+  filterModel: AgGridFilterModel,
+): QueryFilterClause[] | undefined {
+  if (!filterModel || Object.keys(filterModel).length === 0) {

Review Comment:
   How does this take care of filter model having AND , OR operators , Filter 
model looks something like this 
   {
       "time_start": {
           "filterType": "date",
           "operator": "AND",
           "conditions": [
               {
                   "dateFrom": "1996-12-12 00:00:00",
                   "dateTo": null,
                   "filterType": "date",
                   "type": "lessThan"
               },
               {
                   "dateFrom": "1996-12-18 00:00:00",
                   "dateTo": null,
                   "filterType": "date",
                   "type": "equals"
               }
           ]
       }
   }
   
   How do we make sure that the conditions are properly applied with the 
operator, since we dont have conditions array handling here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to