Skip to content

Commit 5b2b181

Browse files
committed
- Edge width should depend on record size.
- Highlight time based on execution time
1 parent 7569daf commit 5b2b181

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

redisinsight/ui/src/packages/ri-explain/src/Explain.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ interface IExplain {
2020
data: [{response: string[] | string | any}]
2121
}
2222

23+
function getEdgeSize(c: number) {
24+
return (Math.log(c || 1) / Math.log(3)) + 1
25+
}
26+
2327
export default function Explain(props: IExplain): JSX.Element {
2428
const command = props.command.split(' ')[0].toLowerCase()
2529

@@ -139,8 +143,12 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
139143
ancestors.pairs.forEach(p => {
140144
const parentNode = document.querySelector(`#node-${p[0]}`)
141145
parentNode?.classList.add('ProfileContainerHover')
142-
document.querySelector(`[data-cell-id='${p[0]}-${p[1]}']`)?.childNodes.forEach(k => {
143-
(k as any).setAttribute("style", "stroke: #85A2FE; stroke-linecap: butt; stroke-width: 2px")
146+
document.querySelector(`[data-cell-id='${p[0]}-${p[1]}']`)?.childNodes.forEach((k: any) => {
147+
148+
const entityNode = document.querySelector(`#node-${p[1]}`) as any
149+
150+
const strokeSize = getEdgeSize(parseInt(entityNode?.dataset?.size)) + 1;
151+
k.setAttribute("style", `stroke: #85A2FE; stroke-linecap: butt; stroke-width: ${strokeSize}px`)
144152
})
145153
})
146154
}
@@ -205,7 +213,6 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
205213
info.recordsProduced = info.counter
206214
delete info.counter
207215
delete info.size
208-
209216
}
210217

211218
let nodeProps = {
@@ -238,6 +245,8 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
238245
}
239246
if (data.children) {
240247
data.children.forEach((item: any) => {
248+
const itemRecords = parseInt(item.data.counter || 0)
249+
241250
model.edges?.push({
242251
id: `${data.id}-${item.id}`,
243252
source: data.id,
@@ -260,7 +269,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
260269
attrs: {
261270
line: {
262271
stroke: isDarkTheme ? '#6B6B6B' : '#8992B3',
263-
strokeWidth: 1,
272+
strokeWidth: getEdgeSize(itemRecords),
264273
targetMarker: null,
265274
},
266275
},

redisinsight/ui/src/packages/ri-explain/src/Node.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,15 @@ export function ProfileNode(props: INodeProps) {
7575
items['Size'] = size
7676
}
7777

78-
if (recordsProduced !== undefined) {
79-
items['Records Produced'] = recordsProduced
78+
const timeInFloat = parseFloat(time || '')
79+
const timeStyles = {
80+
fontWeight: 'bold',
81+
color: 'white',
82+
backgroundColor: (timeInFloat > 45 ? 'red' : timeInFloat > 25 ? 'yellow' : ''),
8083
}
8184

8285
return (
83-
<div className="ProfileContainer" id={`node-${id}`}>
86+
<div className="ProfileContainer" id={`node-${id}`} data-size={counter || size || recordsProduced}>
8487
<div className="Main">
8588
<div>{data ? data : type}</div>
8689
<div className="Type">{[EntityType.GEO, EntityType.NUMERIC, EntityType.TEXT, EntityType.TAG].includes(type) ? type : ''}</div>
@@ -94,12 +97,21 @@ export function ProfileNode(props: INodeProps) {
9497
}
9598
<div className="MetaData">
9699
<EuiToolTip content={<NodeToolTipContent content={"Execution Time"} />}>
97-
<div className="Time">
100+
<div className="Time" style={timeInFloat > 25 ? timeStyles : {}}>
98101
<div className="IconContainer"><EuiIcon className="NodeIcon" size="m" type="clock" /></div>
99102
<div>{time} ms</div>
100103
</div>
101104
</EuiToolTip>
102-
<EuiToolTip content={<NodeToolTipContent items={items} />}>
105+
<EuiToolTip
106+
content={
107+
<NodeToolTipContent
108+
{...{
109+
items: recordsProduced === undefined ? items : undefined,
110+
content: recordsProduced ? 'Records produced' : undefined
111+
}}
112+
/>
113+
}
114+
>
103115
<div className="Size">
104116
<div>{
105117
counter !== undefined ? counter :

0 commit comments

Comments
 (0)