-
Notifications
You must be signed in to change notification settings - Fork 18
feat: specify resource pools when launching a query #3198
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
26 commits
Select commit
Hold shift + click to select a range
05c247c
feat: specify resource pools when launching a query
astandrik c78b945
fix: pass resouce_pool in params
astandrik 9c14943
fix: nothing by default
astandrik 3016085
fix: default pool
astandrik 267da63
fix: default value
astandrik 0c0a12c
fix: default
astandrik f0b1976
fix: default
astandrik a301a76
fix: default
astandrik 0dde76b
fix: review fixes
astandrik 835e61e
fix: add tests
astandrik c1567a2
fix: default value
astandrik 7be0b29
fix: review
astandrik 6fa8ae2
fix: review
astandrik a610eca
fix: review
astandrik f1e08db
fix: tests
astandrik ccf18b7
fix: corner case
astandrik 121fcd7
fix: corner case
astandrik 2bc04f5
fix: reset invalid pool
astandrik 99ee40b
fix: get pools on editor open
astandrik 35d50bd
fix: tests
astandrik 6775ce4
fix: leave only title
astandrik 35d10a2
fix: move controller to bottom
astandrik 9974482
fix: review
astandrik 45e6869
fix: remove only
astandrik 62e8dd8
fix: review
astandrik 59e83ae
fix: review
astandrik 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
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import React from 'react'; | ||
|
|
||
| import {queryApi} from '../../store/reducers/query/query'; | ||
| import {RESOURCE_POOL_NO_OVERRIDE_VALUE} from '../query'; | ||
| import type {ResourcePoolValue} from '../query'; | ||
|
|
||
| type UseResourcePoolsResult = { | ||
| resourcePools: string[]; | ||
| normalizedResourcePool: ResourcePoolValue; | ||
| isLoading: boolean; | ||
| isFetching: boolean; | ||
| error?: unknown; | ||
| }; | ||
|
|
||
| export const useResourcePools = ( | ||
| database: string | undefined, | ||
| resourcePool: ResourcePoolValue | undefined, | ||
| ): UseResourcePoolsResult => { | ||
| const { | ||
| data: resourcePools = [], | ||
| isLoading, | ||
| isFetching, | ||
| error, | ||
| } = queryApi.useGetResourcePoolsQuery( | ||
| {database: database || ''}, | ||
| { | ||
| skip: !database, | ||
| }, | ||
| ); | ||
|
|
||
| const normalizedResourcePool = React.useMemo<ResourcePoolValue>(() => { | ||
| if (!resourcePool || resourcePool === RESOURCE_POOL_NO_OVERRIDE_VALUE) { | ||
| return RESOURCE_POOL_NO_OVERRIDE_VALUE; | ||
| } | ||
|
|
||
| if (!resourcePools.length) { | ||
| // If we couldn't get pools for any reason, fall back to no override | ||
| return RESOURCE_POOL_NO_OVERRIDE_VALUE; | ||
| } | ||
|
|
||
| return resourcePools.includes(resourcePool) | ||
| ? resourcePool | ||
| : RESOURCE_POOL_NO_OVERRIDE_VALUE; | ||
| }, [resourcePool, resourcePools]); | ||
|
|
||
| return {resourcePools, normalizedResourcePool, isLoading, isFetching, error}; | ||
| }; |
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.