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


##########
superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts:
##########
@@ -1456,3 +1458,162 @@ describe('EchartsMixedTimeseries tooltip truncation', 
() => {
     expect(html).not.toContain(longSeriesName);
   });
 });
+
+test('should apply a dashed lineStyle to derived (time comparison) series 
only', () => {

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Consolidate duplicate test code</b></div>
   <div id="fix">
   
   Consider consolidating the duplicate test code found in 
transformProps.test.ts. The test 'should apply a dashed lineStyle to derived 
(time comparison) series only' appears at lines 1462-1497, 1520-1554, and 
1570-1605 with similar setup code. Extracting common test data creation and 
chartProps configuration into reusable helpers would improve maintainability.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #68fd1e</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-echarts/test/MixedTimeseries/transformProps.test.ts:
##########
@@ -1456,3 +1458,162 @@ describe('EchartsMixedTimeseries tooltip truncation', 
() => {
     expect(html).not.toContain(longSeriesName);
   });
 });
+
+test('should apply a dashed lineStyle to derived (time comparison) series 
only', () => {
+  const queryAData = createTestQueryData(
+    [
+      {
+        sum__num: 100,
+        'sum__num__1 week ago': 80,
+        ds: 599616000000,
+      },
+      {
+        sum__num: 150,
+        'sum__num__1 week ago': 120,
+        ds: 599916000000,
+      },
+    ],
+    {
+      label_map: {
+        ds: ['ds'],
+        sum__num: ['sum__num'],
+        'sum__num__1 week ago': ['sum__num__1 week ago'],
+      },
+    },
+  );
+
+  const chartProps = createEchartsTimeseriesTestChartProps<
+    EchartsMixedTimeseriesFormData,
+    EchartsMixedTimeseriesProps
+  >({
+    ...MIXED_TIMESERIES_CHART_PROPS_DEFAULTS,
+    defaultQueriesData: [queryAData, queriesData[1]],
+    formData: {
+      ...formData,
+      metrics: ['sum__num'],
+      groupby: [],
+      time_compare: ['1 week ago'],
+      comparison_type: ComparisonType.Values,
+      timeShiftColor: true,
+    },
+    queriesData: [queryAData, queriesData[1]],

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Refactor cross-file duplicated test code</b></div>
   <div id="fix">
   
   Cross-file duplicate test code detected: The transformProps call and series 
extraction pattern appears in MixedTimeseries/transformProps.test.ts (lines 
1499-1508) and Timeseries/transformProps.test.ts (lines 1101-1110, 1146-1155). 
Consider creating a shared test helper to reduce duplication.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #68fd1e</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-echarts/test/MixedTimeseries/transformProps.test.ts:
##########
@@ -1456,3 +1458,162 @@ describe('EchartsMixedTimeseries tooltip truncation', 
() => {
     expect(html).not.toContain(longSeriesName);
   });
 });
+
+test('should apply a dashed lineStyle to derived (time comparison) series 
only', () => {
+  const queryAData = createTestQueryData(
+    [
+      {
+        sum__num: 100,
+        'sum__num__1 week ago': 80,
+        ds: 599616000000,
+      },
+      {
+        sum__num: 150,
+        'sum__num__1 week ago': 120,
+        ds: 599916000000,
+      },
+    ],
+    {
+      label_map: {
+        ds: ['ds'],
+        sum__num: ['sum__num'],
+        'sum__num__1 week ago': ['sum__num__1 week ago'],
+      },
+    },
+  );
+
+  const chartProps = createEchartsTimeseriesTestChartProps<
+    EchartsMixedTimeseriesFormData,
+    EchartsMixedTimeseriesProps
+  >({
+    ...MIXED_TIMESERIES_CHART_PROPS_DEFAULTS,
+    defaultQueriesData: [queryAData, queriesData[1]],
+    formData: {
+      ...formData,
+      metrics: ['sum__num'],
+      groupby: [],
+      time_compare: ['1 week ago'],
+      comparison_type: ComparisonType.Values,
+      timeShiftColor: true,
+    },
+    queriesData: [queryAData, queriesData[1]],
+  });
+
+  const transformed = transformProps(chartProps);
+  const series = (transformed.echartOptions.series as SeriesOption[]) || [];
+
+  const mainSeries = series.find(s => s.name === 'sum__num') as
+    | (SeriesOption & { lineStyle?: { type?: number[] | string } })
+    | undefined;
+  const derivedSeries = series.find(s => s.name === 'sum__num__1 week ago') as
+    | (SeriesOption & { lineStyle?: { type?: number[] | string } })
+    | undefined;
+
+  expect(mainSeries).toBeDefined();
+  expect(derivedSeries).toBeDefined();
+  // The primary (non-derived) series should not receive a dash pattern
+  expect(mainSeries?.lineStyle?.type).toBeUndefined();
+  // The derived (time comparison) series should receive a dash pattern array
+  expect(Array.isArray(derivedSeries?.lineStyle?.type)).toBe(true);
+});
+
+test('should not apply a dashed lineStyle when comparison_type is not Values', 
() => {
+  const queryAData = createTestQueryData(
+    [
+      {
+        sum__num: 100,
+        'sum__num__1 week ago': 80,
+        ds: 599616000000,
+      },
+      {
+        sum__num: 150,
+        'sum__num__1 week ago': 120,
+        ds: 599916000000,
+      },
+    ],
+    {
+      label_map: {
+        ds: ['ds'],
+        sum__num: ['sum__num'],
+        'sum__num__1 week ago': ['sum__num__1 week ago'],
+      },
+    },
+  );
+
+  const chartProps = createEchartsTimeseriesTestChartProps<
+    EchartsMixedTimeseriesFormData,
+    EchartsMixedTimeseriesProps
+  >({
+    ...MIXED_TIMESERIES_CHART_PROPS_DEFAULTS,
+    defaultQueriesData: [queryAData, queriesData[1]],
+    formData: {
+      ...formData,
+      metrics: ['sum__num'],
+      groupby: [],
+      time_compare: ['1 week ago'],
+      comparison_type: ComparisonType.Difference,

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Merge similar assertion blocks</b></div>
   <div id="fix">
   
   Duplicate assertion code found in transformProps.test.ts at lines 1554-1568 
and 1605-1619. The chartProps creation and series validation logic could be 
extracted into a shared test helper to reduce redundancy.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #68fd1e</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-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -458,6 +471,22 @@ export default function transformProps(
   rawSeriesA.forEach(entry => {
     const entryName = String(entry.name || '');
     const seriesName = inverted[entryName] || entryName;
+    const derivedSeries = isDerivedSeries(
+      entry,
+      chartProps.rawFormData,
+      seriesName,
+    );
+    const lineStyle: LineStyleOption = {};
+    if (derivedSeries && timeShiftColor) {
+      const offset = getTimeOffset(entry, array) || seriesName;

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Extract duplicated source logic</b></div>
   <div id="fix">
   
   Consider extracting duplicated source code logic in transformProps.ts. The 
offset pattern calculation and lineStyle assignment at lines 481-490 and 
585-594 appears to be identical. A shared helper function could reduce code 
duplication and improve maintainability.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #68fd1e</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