-
Notifications
You must be signed in to change notification settings - Fork 92
feat(webui): Display total result count rather than UI table row count for Presto queries. #1236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4ce6adc
latest
6b9cb77
latest
5afa51a
Update components/webui/client/src/pages/SearchPage/SearchQueryStatus…
davemarco 330ef3e
Merge branch 'main' into countUpdate
davemarco a7b9f16
Merge branch 'main' into countUpdate
junhaoliao 8e8ef0f
Merge branch 'main' into countUpdate
hoophalab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,18 +17,25 @@ import {useResultsMetadata} from "./useResultsMetadata"; | |
| const PRESTO_CANCEL_ERROR_NAME = "USER_CANCELED"; | ||
|
|
||
| /** | ||
| * Custom hook to update the UI state to `DONE` when the results metadata signal indicates | ||
| * that the query is complete, or `FAILED` if the query fails. If there is an error, it will | ||
| * also display a notification with the error message. | ||
| * Custom hook to update the client state based on results metadata from the server. | ||
| * - Sets the UI state to `DONE` when the results metadata signal indicates that the query is | ||
| * complete, or `FAILED` if the query fails. If there is an error, it will display a notification | ||
| * with the error message. | ||
| * - Updates the number of search results from the metadata. | ||
| */ | ||
| const useUiUpdateOnDoneSignal = () => { | ||
| const {updateSearchUiState} = useSearchStore(); | ||
| const useUpdateStateWithMetadata = () => { | ||
| const {updateSearchUiState, updateNumSearchResultsMetadata} = useSearchStore(); | ||
| const resultsMetadata = useResultsMetadata(); | ||
|
|
||
|
Comment on lines
+26
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Select store actions with selectors to avoid re-rendering on every state change Destructuring the whole store subscribes to all state changes, causing SearchPage to re-render frequently. Select only the actions needed. Apply this diff: -const useUpdateStateWithMetadata = () => {
- const {updateSearchUiState, updateNumSearchResultsMetadata} = useSearchStore();
+const useUpdateStateWithMetadata = () => {
+ const updateSearchUiState = useSearchStore((s) => s.updateSearchUiState);
+ const updateNumSearchResultsMetadata = useSearchStore((s) => s.updateNumSearchResultsMetadata);
const resultsMetadata = useResultsMetadata();🤖 Prompt for AI Agents |
||
| useEffect(() => { | ||
| if (null === resultsMetadata) { | ||
| return; | ||
| } | ||
|
|
||
| if ("undefined" !== typeof resultsMetadata.numTotalResults) { | ||
| updateNumSearchResultsMetadata(resultsMetadata.numTotalResults); | ||
| } | ||
|
|
||
|
hoophalab marked this conversation as resolved.
|
||
| switch (resultsMetadata.lastSignal) { | ||
| case SEARCH_SIGNAL.RESP_DONE: | ||
| case PRESTO_SEARCH_SIGNAL.FINISHED: | ||
|
|
@@ -59,7 +66,8 @@ const useUiUpdateOnDoneSignal = () => { | |
| }, [ | ||
| resultsMetadata, | ||
| updateSearchUiState, | ||
| updateNumSearchResultsMetadata, | ||
| ]); | ||
| }; | ||
|
|
||
| export {useUiUpdateOnDoneSignal}; | ||
| export {useUpdateStateWithMetadata}; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Consider resetting metadata count at query start to avoid stale max() values
Initialising to 0 is fine, but if a new query begins and the first metadata payload lacks numTotalResults, the previous query’s (possibly large) metadata count can linger and dominate the max(metadata, timeline, table) in Results.tsx. Ensure this field is explicitly reset to 0 on new query start or when a new results set (_id) is detected.
Run this to find where the metadata count is reset on query start and whether a 0 reset exists:
🏁 Script executed:
Length of output: 121
I’ll retry the grep without relying on
--type=tsxsupport:🏁 Script executed:
Length of output: 783
Ensure metadata count is reset on every new query
The handler
updateNumSearchResultsMetadatais only invoked whenresultsMetadata.numTotalResultsis defined—there’s no explicit reset to 0 when a query starts or when a new results set (_id) arrives. As a result, if the first payload of a new query omitsnumTotalResults, the previous (larger) value will persist and skew anymax()calculations inResults.tsx.Please add an explicit reset to 0 in
useUpdateStateWithMetadata.ts, for example:• File: components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts
This guarantees stale values are cleared before processing each new result set.
🤖 Prompt for AI Agents