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


##########
superset-frontend/src/filters/components/DateRange/transformProps.ts:
##########
@@ -0,0 +1,62 @@
+/**
+ * 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 { ChartProps } from '@superset-ui/core';
+import { noOp } from 'src/utils/common';
+import { DEFAULT_FORM_DATA } from './types';
+
+export default function transformProps(chartProps: ChartProps) {
+  const {
+    formData,
+    height,
+    hooks,
+    queriesData,
+    width,
+    behaviors,
+    filterState,
+    inputRef,
+  } = chartProps;
+  const {
+    setDataMask = noOp,
+    setHoveredFilter = noOp,
+    unsetHoveredFilter = noOp,
+    setFocusedFilter = noOp,
+    unsetFocusedFilter = noOp,
+    setFilterActive = noOp,
+  } = hooks;
+  const [{ data }] = queriesData;

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Unguarded queriesData destructure</b></div>
   <div id="fix">
   
   `const [{ data }] = queriesData;` throws `TypeError: Cannot destructure 
property 'data' of 'undefined'` when `queriesData` is empty — `ChartProps` 
defaults it to `[]` (ChartProps.ts:207). The sibling 
`Select/transformProps.ts:57-58` guards with `queryData || {}` and `data = []`. 
Mirror that guard to avoid a crash on render.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #2494c9</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/src/constants.ts:
##########
@@ -200,6 +200,7 @@ export enum FilterPlugins {
   Time = 'filter_time',
   TimeColumn = 'filter_timecolumn',
   TimeGrain = 'filter_timegrain',
+  DateRange = 'filter_date_range',

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Report drops new filter type</b></div>
   <div id="fix">
   
   Registering `filter_date_range` makes it selectable, but the report path 
never handles it: `AlertReportModal.tsx` serializes `filterType: 
'filter_date_range'` (line 946-960), and backend `_generate_native_filter` 
(superset/reports/models.py:274-380) has no branch for it, so it hits the 
'unrecognized filter type' warning and the filter is silently dropped from 
report output. Add a `filter_date_range` branch emitting 
`extraFormData.time_range`.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #2494c9</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/src/filters/components/DateRange/controlPanel.ts:
##########
@@ -0,0 +1,46 @@
+/**
+ * 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 { ControlPanelConfig } from '@superset-ui/chart-controls';
+import { t } from '@apache-superset/core/translation';
+
+const config: ControlPanelConfig = {
+  controlPanelSections: [
+    {
+      label: t('UI Configuration'),
+      expanded: true,
+      controlSetRows: [
+        [
+          {
+            name: 'enableEmptyFilter',

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Dead control, no effect</b></div>
   <div id="fix">
   
   This new `enableEmptyFilter` checkbox has no consumer: 
`DateRangeFilterPlugin.tsx`, `transformProps.ts`, and `types.ts` never read it 
(0 matches), unlike `RangeFilterPlugin.validateRange` which enforces it. Users 
toggling 'Filter value is required' get no behavior change. Wire it into 
`handleChange` or drop the control.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #2494c9</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/src/filters/components/DateRange/utils.ts:
##########
@@ -0,0 +1,39 @@
+/**
+ * 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 dayjs, { Dayjs } from 'dayjs';
+
+export const DATE_FORMAT = 'YYYY-MM-DD';
+export const RANGE_SEPARATOR = ' : ';
+
+export type DateRangeValue = [Dayjs | null, Dayjs | null] | null;
+
+export function parseTimeRange(value?: string | null): DateRangeValue {
+  if (!value) return null;
+  const [start, end] = value.split(RANGE_SEPARATOR);
+  const startDate = dayjs(start);
+  const endDate = dayjs(end);
+  if (!startDate.isValid() || !endDate.isValid()) return null;

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing-separator date misparsed</b></div>
   <div id="fix">
   
   `parseTimeRange('2024-01-01')` (no `RANGE_SEPARATOR`) yields `end === 
undefined`, and `dayjs(undefined)` returns the *current* date (valid), so a 
single-date value silently becomes `[now, now]` instead of `null`. Guard 
`!start || !end` before parsing. The backend `get_since_until` 
(date_parser.py:526) uses the same `" : "` separator, so a bare date is not a 
valid range.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #2494c9</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