This repository was archived by the owner on May 13, 2025. It is now read-only.
-
-
Couldn't load subscription status.
- Fork 36
Query engine #320
Merged
Merged
Query engine #320
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
48a64b3
Added support for multiple query engine
Koustavd18 b5fdbae
Minor changes
Koustavd18 13fef93
resolved conflicts
Koustavd18 4ad88b5
added missing escape characters from query
Koustavd18 41c1cdb
query engine based resource path and query generator:
Koustavd18 5c115de
Merge branch 'main' into queryEngine
Koustavd18 ea7276a
clean up
Koustavd18 512ac83
Changes to query builder
Koustavd18 46b2d84
Filter Query Builder
Koustavd18 440f142
Filter Query Builder
Koustavd18 c6aa9fe
type declaration fixes
Koustavd18 e551a0f
getResourcePath method
Koustavd18 44bdf47
optimised info api calls
Koustavd18 97676ca
removed limit clause from count query
Koustavd18 e310794
removed limit clause from count query
Koustavd18 d8845e4
footer count failing solved
Koustavd18 a9b2db2
minor fixes
Koustavd18 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
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 |
|---|---|---|
|
|
@@ -8,8 +8,10 @@ import { logsStoreReducers, useLogsStore } from '@/pages/Stream/providers/LogsPr | |
| import _ from 'lodash'; | ||
| import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider'; | ||
| import { notifyError } from '@/utils/notification'; | ||
| import { QueryEngineType } from '@/@types/parseable/api/about'; | ||
|
|
||
| type QueryData = { | ||
| queryEngine: QueryEngineType; | ||
| logsQuery: LogsQuery; | ||
| query: string; | ||
| onSuccess?: () => void; | ||
|
|
@@ -18,7 +20,7 @@ type QueryData = { | |
|
|
||
| export const useQueryResult = () => { | ||
| const fetchQueryHandler = async (data: QueryData) => { | ||
| const response = await getQueryResultWithHeaders(data.logsQuery, data.query, data.useTrino); | ||
| const response = await getQueryResultWithHeaders(data.logsQuery, data.query); | ||
| if (response.status !== 200) { | ||
| throw new Error(response.statusText); | ||
| } | ||
|
|
@@ -62,9 +64,14 @@ export const useFetchCount = () => { | |
| if (isQuerySearchActive) { | ||
| const finalQuery = custSearchQuery.replace(/SELECT[\s\S]*?FROM/i, 'SELECT COUNT(*) as count FROM'); | ||
| if (activeMode === 'filters') { | ||
| return finalQuery; | ||
| return finalQuery | ||
| .replace(/LIMIT\s*\d+\s*(OFFSET\s*\d+)?\s*;?/i, '') // Removes LIMIT and optional OFFSET | ||
| .replace(/OFFSET\s*\d+\s*;?/i, ''); | ||
| } else { | ||
| return finalQuery.replace(/ORDER\s+BY\s+[\w\s,.]+(?:ASC|DESC)?\s*(LIMIT\s+\d+)?\s*;?/i, ''); | ||
| return finalQuery | ||
| .replace(/ORDER\s+BY\s+[\w\s,.]+(?:ASC|DESC)?\s*(LIMIT\s*\d+)?\s*(OFFSET\s*\d+)?\s*;?/i, '') // Removes ORDER BY, LIMIT, and OFFSET | ||
| .replace(/LIMIT\s*\d+\s*(OFFSET\s*\d+)?\s*;?/i, '') // Removes LIMIT and optional OFFSET | ||
| .replace(/OFFSET\s*\d+\s*;?/i, ''); | ||
|
||
| } | ||
| } else { | ||
| return defaultQuery; | ||
|
|
@@ -80,15 +87,21 @@ export const useFetchCount = () => { | |
| isLoading: isCountLoading, | ||
| isRefetching: isCountRefetching, | ||
| refetch: refetchCount, | ||
| } = useQuery(['fetchCount', logsQuery], () => getQueryResult(logsQuery, query, false), { | ||
| onSuccess: (resp) => { | ||
| const count = _.first(resp.data)?.count; | ||
| } = useQuery( | ||
| ['fetchCount', logsQuery], | ||
| async () => { | ||
| const data = await getQueryResult(logsQuery, query); | ||
| const count = _.first(data.data)?.count; | ||
| typeof count === 'number' && setLogsStore((store) => setTotalCount(store, count)); | ||
| return data; | ||
| }, | ||
| refetchOnWindowFocus: false, | ||
| retry: false, | ||
| enabled: false, | ||
| }); | ||
| { | ||
| // query for count should always hit the endpoint for parseable query | ||
| refetchOnWindowFocus: false, | ||
| retry: false, | ||
| enabled: false, | ||
| }, | ||
| ); | ||
|
|
||
| return { | ||
| isCountLoading, | ||
|
|
||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Why'd we did a class implementation ? The created instance was never passed outside this function. So there is no need for a class here.
Give a read on Separation of concern.
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.
Problem we want to solve is that earlier there was this useTrino flag passed around everywhere which is error prone. How do you propose to fix that?
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.
Oh ok then.
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.
I am more than happy if you can propose a better / idiomatic approach on how to do this.
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.
Stating all the above, we dont really need a class. Instead of passing the string everywhere, pass just the boolean since thats what we need at the end. Revert back all the changes and just set and set the useTrino (boolean) in the app provider.
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.
We have to avoid this. It has to dynamically decide which engine to use based on API response.
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.
Thats a very valid point if we are going to add more connectors.
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.
Right now there is one, but we have to make it modular so we can extend as needed
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.
about the endpoint def. 1 function to dynamically decide or separate endpoints for every connectors?
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.
If we are going to include more connectors:
Then the class should provide everything for making a request.
All the logic related to query engine should be inside the class. Define separate urls for separate engines and the class should decide and return the url also.