bito-code-review[bot] commented on code in PR #41024:
URL: https://github.com/apache/superset/pull/41024#discussion_r3457582839


##########
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts:
##########
@@ -54,7 +54,7 @@ export function getQueryMode(formData: TableChartFormData) {
   return hasRawColumns ? QueryMode.Raw : QueryMode.Aggregate;
 }
 
-const buildQuery: BuildQuery<TableChartFormData> = (
+export const buildQuery: BuildQuery<TableChartFormData> = (

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Large duplicated code block (204 tokens)</b></div>
   <div id="fix">
   
   Code duplication detected: 31 lines of buildQuery implementation are 
duplicated between plugin-chart-table/src/buildQuery.ts (lines 57-87) and 
plugin-chart-ag-grid-table/src/buildQuery.ts (lines 61-91). Additional similar 
duplications exist at lines 182-221, 230-244, and 278-290 in plugin-chart-table 
and corresponding lines in plugin-chart-ag-grid-table. Consider extracting the 
common buildQuery logic into a shared utility module.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #f34659</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset-frontend/plugins/plugin-chart-table/src/buildQuery.ts:
##########
@@ -217,6 +217,17 @@ const buildQuery: BuildQuery<TableChartFormData> = (
 
     const moreProps: Partial<QueryObject> = {};
     const ownState = options?.ownState ?? {};
+    // Server pagination sizing, shared between the per-page request below and
+    // the filter-change reset further down.
+    const pageSize =
+      Number(ownState.pageSize ?? formDataCopy.server_page_length) || 0;
+    const configuredRowLimit = Number(formDataCopy.row_limit) || 0;
+    // row_limit for the first page, capped by the configured row limit. Used
+    // when a filter change resets pagination back to page 0.
+    const firstPageRowLimit =
+      configuredRowLimit > 0
+        ? Math.min(pageSize, configuredRowLimit)
+        : pageSize;

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Small duplicated code block (72 tokens)</b></div>
   <div id="fix">
   
   Duplicate code identified: 15 lines of ownState handling and isDownloadQuery 
detection logic duplicated between plugin-chart-table/src/buildQuery.ts (lines 
230-244) and plugin-chart-ag-grid-table/src/buildQuery.ts (lines 205-219). This 
is part of a larger pattern of duplication in these buildQuery implementations.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #f34659</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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