File tree Expand file tree Collapse file tree 6 files changed +55
-15
lines changed
Info/Retrieval/RetrievalTable Expand file tree Collapse file tree 6 files changed +55
-15
lines changed Original file line number Diff line number Diff line change 66 */
77
88import { request } from 'helpers/request'
9+ import { formatInstanceRetrieval } from '@postgres.ai/shared/types/api/entities/instanceRetrieval'
910
1011export const getInstanceRetrieval = async ( ) => {
1112 const response = await request ( '/instance/retrieval' )
1213
1314 return {
14- response : response . ok ? response : null ,
15+ response : response . ok ? formatInstanceRetrieval ( await response . json ( ) ) : null ,
1516 error : response . ok ? null : response ,
1617 }
1718}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export const RetrievalTable = ({
2020 < Table >
2121 < TableHead >
2222 < TableRow >
23- < TableCell > Activity on the { activity } </ TableCell >
23+ < TableCell className = { styles . tableSubtitle } > Activity on the { activity } </ TableCell >
2424 </ TableRow >
2525 </ TableHead >
2626 < TableBody className = { styles . tableBody } >
@@ -30,16 +30,20 @@ export const RetrievalTable = ({
3030 { Object . entries ( item ) . map ( ( val , index ) => (
3131 < TableRow key = { index } hover className = { styles . tableRow } >
3232 < TableCell >
33- { val [ 0 ] } : { val [ 1 ] }
33+ { val [ 0 ] } : { val [ 1 ] }
3434 </ TableCell >
3535 </ TableRow >
3636 ) ) }
3737 </ div >
3838 ) )
3939 ) : (
40- < TableRow className = { styles . tableRow } >
41- < TableCell > No activity on the { activity } </ TableCell >
42- </ TableRow >
40+ < TableBody className = { styles . tableBody } >
41+ < div >
42+ < TableRow className = { styles . tableRow } >
43+ < TableCell > No activity on the { activity } </ TableCell >
44+ </ TableRow >
45+ </ div >
46+ </ TableBody >
4347 ) }
4448 </ TableBody >
4549 </ Table >
Original file line number Diff line number Diff line change 1212 }
1313
1414 div {
15- padding-bottom : 0.75rem ;
15+ padding : 0.75rem 0 ;
1616 }
1717
1818 td {
1919 border-bottom : 0 ;
20- padding : 12px 18px ;
20+ padding : 0px 18px ;
21+ font-size : 13px ;
22+ font-family : ' Fira Code' , monospace ;
2123 }
2224}
25+
26+ .tableSubtitle {
27+ font-size : 15px ;
28+ font-weight : bold ;
29+ }
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ import { getTextFromUnknownApiError } from '@postgres.ai/shared/utils/api'
2323import { dbSource } from 'types/api/entities/dbSource'
2424import { GetFullConfig } from 'types/api/endpoints/getFullConfig'
2525import { GetInstanceRetrieval } from 'types/api/endpoints/getInstanceRetrieval'
26- import { InstanceRetrieval } from 'types/api/entities/instanceRetrieval'
26+ import { InstanceRetrievalType } from 'types/api/entities/instanceRetrieval'
2727
2828const POLLING_TIME = 2000
2929
@@ -51,7 +51,7 @@ type Error = {
5151
5252export class MainStore {
5353 instance : Instance | null = null
54- instanceRetrieval : InstanceRetrieval | null = null
54+ instanceRetrieval : InstanceRetrievalType | null = null
5555 config : Config | null = null
5656 fullConfig ?: string
5757 instanceError : Error | null = null
@@ -108,7 +108,7 @@ export class MainStore {
108108 } )
109109
110110 if ( response )
111- this . instanceRetrieval = await response ?. json ( )
111+ this . instanceRetrieval = response
112112
113113 if ( error )
114114 this . instanceError = { message : await getTextFromUnknownApiError ( error ) }
Original file line number Diff line number Diff line change 1+ import { InstanceRetrievalType } from '@postgres.ai/shared/types/api/entities/instanceRetrieval'
2+
13export type GetInstanceRetrieval = ( args : { instanceId : string } ) => Promise < {
2- response : Response | null
4+ response : InstanceRetrievalType | null
35 error : Response | null
46} >
Original file line number Diff line number Diff line change 11export interface ActivityType {
22 user ?: string
33 query ?: string
4- duration ?: string
5- wait_event_type ?: string
6- wait_event ?: string
4+ duration ?: number | string
5+ waitEventType ?: string
6+ waitEvent ?: string
77}
88
99export type InstanceRetrieval = {
@@ -18,3 +18,29 @@ export type InstanceRetrieval = {
1818 target : ActivityType [ ]
1919 }
2020}
21+
22+ const replaceSinglequote = ( string ?: string ) => string ?. replace ( / ' / g, '' )
23+
24+ const formatActivity = ( activity : ActivityType [ ] ) =>
25+ activity ?. map ( ( item ) => {
26+ return {
27+ user : replaceSinglequote ( item . user ) ,
28+ query : replaceSinglequote ( item . query ) ,
29+ duration : replaceSinglequote ( `${ item . duration } ms` ) ,
30+ 'wait type/event' : replaceSinglequote (
31+ `${ item . waitEventType } /${ item . waitEvent } ` ,
32+ ) ,
33+ }
34+ } )
35+
36+ export const formatInstanceRetrieval = ( retrieval : InstanceRetrieval ) => {
37+ return {
38+ ...retrieval ,
39+ activity : {
40+ source : formatActivity ( retrieval . activity ?. source ) ,
41+ target : formatActivity ( retrieval . activity ?. target ) ,
42+ } ,
43+ }
44+ }
45+
46+ export type InstanceRetrievalType = ReturnType < typeof formatInstanceRetrieval >
You can’t perform that action at this time.
0 commit comments