diff --git a/changes/24653-live-query-from-edit-affects-performance-stats b/changes/24653-live-query-from-edit-affects-performance-stats new file mode 100644 index 000000000000..68becee779c9 --- /dev/null +++ b/changes/24653-live-query-from-edit-affects-performance-stats @@ -0,0 +1,2 @@ +- When running a live query from the edit query form, consider the results of the run in calculating + an existing query's performance impact if the user didn't change the query from the stored version. diff --git a/frontend/pages/queries/edit/components/EditQueryForm/EditQueryForm.tsx b/frontend/pages/queries/edit/components/EditQueryForm/EditQueryForm.tsx index 2decb1260b79..41170b7ed4d1 100644 --- a/frontend/pages/queries/edit/components/EditQueryForm/EditQueryForm.tsx +++ b/frontend/pages/queries/edit/components/EditQueryForm/EditQueryForm.tsx @@ -184,6 +184,7 @@ const EditQueryForm = ({ const [isEditingDescription, setIsEditingDescription] = useState(false); const [isSaveAsNewLoading, setIsSaveAsNewLoading] = useState(false); const [showAdvancedOptions, setShowAdvancedOptions] = useState(false); + const [queryWasChanged, setQueryWasChanged] = useState(false); const platformCompatibility = usePlatformCompatibility(); const { setCompatiblePlatforms } = platformCompatibility; @@ -233,6 +234,7 @@ const EditQueryForm = ({ }; const onChangeQuery = (sqlString: string) => { + setQueryWasChanged(true); setLastEditedQueryBody(sqlString); }; @@ -882,7 +884,17 @@ const EditQueryForm = ({ className={`${baseClass}__run`} variant="blue-green" onClick={() => { - setEditingExistingQuery(true); // Persists edited query data through live query flow + // calling `setEditingExistingQuery` here prevents + // inclusion of `query_id` in the subsequent `run` API call, which prevents counting + // this live run in performance impact. Since we DO want to count this run in those + // stats if the query is the same as the saved one, only set below IF the query + // has been changed. + // TODO - product: should host details > action > query >