-
Notifications
You must be signed in to change notification settings - Fork 17
feat: snippets for table (under tree dots in navigation tree) #1476
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
Changes from 4 commits
c198207
afab4eb
adc597a
9e3b29d
2efd40c
d81165a
df0abde
d537ae4
e4c3198
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { | ||
| prepareSchemaData, | ||
| prepareViewSchema, | ||
| } from '../../containers/Tenant/Schema/SchemaViewer/prepareData'; | ||
| import type {SchemaData} from '../../containers/Tenant/Schema/SchemaViewer/types'; | ||
| import {isViewType} from '../../containers/Tenant/utils/schema'; | ||
| import type {EPathType} from '../../types/api/schema'; | ||
| import {isQueryErrorResponse} from '../../utils/query'; | ||
|
|
||
| import {api} from './api'; | ||
| import {overviewApi} from './overview/overview'; | ||
| import {viewSchemaApi} from './viewSchema/viewSchema'; | ||
|
|
||
| export interface GetTableSchemaDataParams { | ||
| path: string; | ||
| tenantName: string; | ||
| type: EPathType; | ||
| } | ||
|
|
||
| const TABLE_SCHEMA_TIMEOUT = 1000; | ||
|
|
||
| const getTableSchemaDataConcurrentId = 'getTableSchemaData'; | ||
|
|
||
| export const tableSchemeDataApi = api.injectEndpoints({ | ||
| endpoints: (build) => ({ | ||
| getTableSchemaData: build.mutation<SchemaData[], GetTableSchemaDataParams>({ | ||
| queryFn: async ({path, tenantName, type}, {dispatch}) => { | ||
| try { | ||
| const schemaData = await dispatch( | ||
|
||
| overviewApi.endpoints.getOverview.initiate({ | ||
| paths: [path], | ||
| database: tenantName, | ||
| timeout: TABLE_SCHEMA_TIMEOUT, | ||
| concurrentId: getTableSchemaDataConcurrentId + 'getOverview', | ||
|
||
| }), | ||
| ); | ||
|
|
||
| if (isViewType(type)) { | ||
| const response = await dispatch( | ||
| viewSchemaApi.endpoints.getViewSchema.initiate({ | ||
| database: tenantName, | ||
| path, | ||
| timeout: TABLE_SCHEMA_TIMEOUT, | ||
| concurrentId: getTableSchemaDataConcurrentId + 'getViewSchema', | ||
| }), | ||
| ); | ||
|
|
||
| if (isQueryErrorResponse(response)) { | ||
| return {error: response}; | ||
| } | ||
|
|
||
| const result = prepareViewSchema(response.data); | ||
| return {data: result}; | ||
| } | ||
|
|
||
| const result = prepareSchemaData(type, schemaData.data?.data); | ||
|
|
||
| return {data: result}; | ||
| } catch (error) { | ||
| return {error}; | ||
| } | ||
| }, | ||
| }), | ||
| }), | ||
| }); | ||
|
|
||
| export const {useGetTableSchemaDataMutation} = tableSchemeDataApi; | ||
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 think you should exclude
timeout(and probablyconcurrentId) inserializeQueryArgs, otherwise yourgetTableSchemaDatawill always initiate a new request and will never reuse data from other request tooverviewApiThere 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.
In current versions there is always a new request, even if entity overview have already been loaded
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.
removed timeout and concurrentId
now queries use same api and timeout moved to front with Promise.race and wait