jsk1004ha commented on code in PR #43376:
URL: https://github.com/apache/superset/pull/43376#discussion_r4084145104


##########
superset-frontend/src/dashboard/components/SliceHeaderControls/SliceHeaderControls.test.tsx:
##########
@@ -616,10 +616,14 @@ test('Should show "View query"', () => {
     Admin: [['can_view_query', 'Dashboard']],
   });
   openMenu();
-  expect(screen.getByText('View query')).toBeInTheDocument();
+  userEvent.click(screen.getByText('Query inspector'));
+  expect(screen.getByRole('tab', { name: 'Stats' })).toBeInTheDocument();

Review Comment:
   Addressed in `9d6d05a`: added `queriesResponse: null` to the fixture so this 
test exercises the query-only case. Thanks for reproducing it!



##########
superset-frontend/src/explore/components/controls/ViewQueryModal.tsx:
##########
@@ -119,6 +180,70 @@ const ViewQueryModal: FC<Props> = ({ latestQueryFormData, 
ownState }) => {
       ))}
     </ViewQueryModalContainer>
   );
+
+  if (queriesResponse === undefined) {
+    return queryContent;
+  }
+
+  const {
+    cachedQueries,
+    queryCount,
+    responseBytes,
+    returnedRows,
+    serializedResponse,
+  } = getResponseStats(queriesResponse);
+  const duration =
+    chartUpdateStartTime != null && chartUpdateEndTime != null
+      ? Math.max(0, chartUpdateEndTime - chartUpdateStartTime)

Review Comment:
   Addressed in `9d6d05a`: a stopped refresh now passes a null end time, so its 
duration is unavailable while the response stats still describe the last 
successful response. Thanks!



##########
superset-frontend/src/explore/components/controls/ViewQueryModal.tsx:
##########
@@ -51,7 +58,64 @@ const ViewQueryModalContainer = styled.div`
   gap: ${({ theme }) => theme.sizeUnit * 4}px;
 `;
 
-const ViewQueryModal: FC<Props> = ({ latestQueryFormData, ownState }) => {
+const InspectorContainer = styled.div`
+  height: 100%;
+
+  .ant-tabs,
+  .ant-tabs-content,
+  .ant-tabs-tabpane {
+    height: 100%;
+  }
+
+  .ant-tabs-tabpane {
+    overflow: auto;
+  }
+`;
+
+const StatsGrid = styled.dl`
+  display: grid;
+  grid-template-columns: max-content 1fr;
+  gap: ${({ theme }) => theme.sizeUnit * 3}px
+    ${({ theme }) => theme.sizeUnit * 6}px;
+  margin: 0;
+
+  dt {
+    color: ${({ theme }) => theme.colorTextSecondary};
+  }
+
+  dd {
+    margin: 0;
+  }
+`;
+
+const getResponseStats = (queriesResponse: QueryData[] | null) => {
+  const responses = queriesResponse ?? [];
+  const serializedResponse = JSON.stringify(responses, null, 2);
+  const returnedRows = responses.reduce((total, response) => {
+    const { data } = response as JsonObject;
+    return total + (Array.isArray(data) ? data.length : 0);
+  }, 0);
+  const cachedQueries = responses.filter(
+    response => (response as JsonObject).is_cached === true,
+  ).length;
+
+  return {
+    cachedQueries,
+    queryCount: responses.length,
+    responseBytes: new Blob([JSON.stringify(responses)]).size,

Review Comment:
   Addressed in `9d6d05a`: null responses now show the size as unavailable, 
while an empty response still reports 2 bytes. Thanks!



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