-
Notifications
You must be signed in to change notification settings - Fork 83
feat(webui): Display search results in Presto UI. #1179
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 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
aca6241
latest
5eea062
latest
d23ba77
latest
af59d56
latest
f3dec72
Merge branch 'main' into datat
hoophalab 3a8caa0
Merge branch 'main' into datat
davemarco e969603
latest
d8bc69b
latest
3c639fb
latest
db8e2eb
fix lint
4e055f5
latest
5281937
latest
527cb19
latest
9cdcebb
Merge branch 'main' into datat
davemarco ddaba31
Merge branch 'main' into datat
hoophalab 085ba38
latest
12222c2
Merge branch 'main' into datat
davemarco 2118902
latest
90caa4e
latest
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
48 changes: 48 additions & 0 deletions
48
...rc/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import {useEffect} from "react"; | ||
|
|
||
| import VirtualTable from "../../../../../components/VirtualTable"; | ||
| import useSearchStore from "../../../SearchState/index"; | ||
| import { | ||
| getPrestoSearchResultsTableColumns, | ||
| PrestoSearchResult, | ||
| } from "./typings"; | ||
| import {usePrestoSearchResults} from "./usePrestoSearchResults"; | ||
|
|
||
|
|
||
| interface PrestoResultsVirtualTableProps { | ||
| tableHeight: number; | ||
| } | ||
|
|
||
| /** | ||
| * Renders Presto search results in a virtual table. | ||
| * | ||
| * @param props | ||
| * @param props.tableHeight | ||
| * @return | ||
| */ | ||
| const PrestoResultsVirtualTable = ({tableHeight}: PrestoResultsVirtualTableProps) => { | ||
| const {updateNumSearchResultsTable} = useSearchStore(); | ||
| const prestoSearchResults = usePrestoSearchResults(); | ||
|
|
||
| useEffect(() => { | ||
| const num = prestoSearchResults ? | ||
| prestoSearchResults.length : | ||
| 0; | ||
|
|
||
| updateNumSearchResultsTable(num); | ||
| }, [ | ||
| prestoSearchResults, | ||
| updateNumSearchResultsTable | ||
| ]); | ||
|
|
||
| return ( | ||
| <VirtualTable<PrestoSearchResult> | ||
| columns={getPrestoSearchResultsTableColumns(prestoSearchResults || [])} | ||
| dataSource={prestoSearchResults || []} | ||
davemarco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pagination={false} | ||
| rowKey={(record) => record._id} | ||
| scroll={{y: tableHeight}}/> | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| }; | ||
|
|
||
| export default PrestoResultsVirtualTable; | ||
35 changes: 35 additions & 0 deletions
35
...nts/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx
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 |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import {TableProps} from "antd"; | ||
|
|
||
|
|
||
| /** | ||
| * Structure of Presto search results data (dynamic properties). | ||
| */ | ||
| interface PrestoSearchResult { | ||
| _id: string; | ||
| row: Record<string, unknown>; | ||
| } | ||
davemarco marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Columns configuration for Presto query engine (dynamic based on data). | ||
| * | ||
| * @param data Array of Presto search results | ||
| * @return | ||
| */ | ||
| const getPrestoSearchResultsTableColumns = ( | ||
| data: PrestoSearchResult[] | ||
| ): NonNullable<TableProps<PrestoSearchResult>["columns"]> => { | ||
| if (0 === data.length || "undefined" === typeof data[0] || "undefined" === typeof data[0].row) { | ||
| return []; | ||
| } | ||
davemarco marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return Object.keys(data[0].row) | ||
| .map((key) => ({ | ||
| dataIndex: ["row", | ||
| key], | ||
| key: key, | ||
| title: key, | ||
| })); | ||
davemarco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| export type {PrestoSearchResult}; | ||
| export {getPrestoSearchResultsTableColumns}; | ||
48 changes: 48 additions & 0 deletions
48
...nt/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import MongoSocketCollection from "../../../../../api/socket/MongoSocketCollection"; | ||
| import {useCursor} from "../../../../../api/socket/useCursor"; | ||
| import useSearchStore, {SEARCH_STATE_DEFAULT} from "../../../SearchState/index"; | ||
| import {SEARCH_MAX_NUM_RESULTS} from "../typings"; | ||
| import {PrestoSearchResult} from "./typings"; | ||
|
|
||
|
|
||
| /** | ||
| * Custom hook to get Presto search results for the current searchJobId. | ||
| * | ||
| * @return | ||
| */ | ||
| const usePrestoSearchResults = () => { | ||
| const {searchJobId} = useSearchStore(); | ||
|
|
||
| const searchResultsCursor = useCursor<PrestoSearchResult>( | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| () => { | ||
| // If there is no active search job, there are no results to fetch. The cursor will | ||
| // return null. | ||
| if (searchJobId === SEARCH_STATE_DEFAULT.searchJobId) { | ||
| return null; | ||
| } | ||
|
|
||
| console.log( | ||
| `Subscribing to updates to Presto search results with job ID: ${searchJobId}` | ||
| ); | ||
davemarco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Retrieve 1k most recent results. | ||
| const options = { | ||
| sort: [ | ||
| [ | ||
| "_id", | ||
| "desc", | ||
| ], | ||
| ], | ||
| limit: SEARCH_MAX_NUM_RESULTS, | ||
| }; | ||
|
|
||
| const collection = new MongoSocketCollection(searchJobId.toString()); | ||
davemarco marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return collection.find({}, options); | ||
| }, | ||
| [searchJobId] | ||
| ); | ||
|
|
||
| return searchResultsCursor; | ||
| }; | ||
|
|
||
| export {usePrestoSearchResults}; | ||
48 changes: 48 additions & 0 deletions
48
...lient/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable.tsx
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import {useEffect} from "react"; | ||
|
|
||
| import VirtualTable from "../../../../components/VirtualTable"; | ||
| import useSearchStore from "../../SearchState/index"; | ||
| import { | ||
| SearchResult, | ||
| searchResultsTableColumns, | ||
| } from "./typings"; | ||
| import {useSearchResults} from "./useSearchResults"; | ||
|
|
||
|
|
||
| interface SearchResultsVirtualTableProps { | ||
| tableHeight: number; | ||
| } | ||
|
|
||
| /** | ||
| * Renders search results in a virtual table. | ||
| * | ||
| * @param props | ||
| * @param props.tableHeight | ||
| * @return | ||
| */ | ||
| const SearchResultsVirtualTable = ({tableHeight}: SearchResultsVirtualTableProps) => { | ||
| const {updateNumSearchResultsTable} = useSearchStore(); | ||
| const searchResults = useSearchResults(); | ||
|
|
||
| useEffect(() => { | ||
| const num = searchResults ? | ||
hoophalab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| searchResults.length : | ||
| 0; | ||
|
|
||
| updateNumSearchResultsTable(num); | ||
| }, [ | ||
| searchResults, | ||
| updateNumSearchResultsTable, | ||
| ]); | ||
|
|
||
| return ( | ||
| <VirtualTable<SearchResult> | ||
| columns={searchResultsTableColumns} | ||
| dataSource={searchResults || []} | ||
| pagination={false} | ||
| rowKey={(record) => record._id.toString()} | ||
| scroll={{y: tableHeight}}/> | ||
| ); | ||
| }; | ||
|
|
||
| export default SearchResultsVirtualTable; | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.