Skip to content

Commit bd96086

Browse files
committed
fix query tool with mutiple health services
1 parent 6922aa7 commit bd96086

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

app/components/TransferColumns.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { QueryContext } from '../context/QueryContext';
88
import { HealthContext } from '../context/HealthContext';
99
import { EventContext } from '../context/EventContext';
1010
import AvQueuePlayNext from 'material-ui/svg-icons/av/queue-play-next';
11+
import { useIsMount } from '../context/helpers';
1112

1213
const TableTransfer = ({ leftColumns, rightColumns, ...restProps }) => (
1314
<Transfer {...restProps}>
@@ -79,6 +80,7 @@ const TransferColumns = React.memo(() => {
7980

8081
const eventDataList = eventData.eventDataList;
8182
const healthDataList = healthData.healthDataList;
83+
const isMount = useIsMount();
8284

8385
useEffect(()=>{
8486
if(healthDataList && healthDataList.length >0){
@@ -106,10 +108,19 @@ const TransferColumns = React.memo(() => {
106108

107109
},[eventMetricsReady]);
108110

111+
112+
109113
useEffect(()=>{
110-
console.log("current service:", service)
114+
// if(isMount){//skip first render
115+
// return;
116+
// }
117+
console.log("current service:", service);
118+
console.log("healthData in else:", healthDataList.length);
119+
console.log("eventData in else:", eventDataList.length);
120+
console.log("healthMetricsReady:", healthMetricsReady);
121+
console.log("eventMetricsReady:", eventMetricsReady);
111122
if(service === ''){
112-
//pass
123+
return;
113124
}
114125
else if(service === 'kafkametrics'){
115126
// console.log("set event metrics:", JSON.stringify(eventMetrics));
@@ -122,20 +133,22 @@ const TransferColumns = React.memo(() => {
122133
}
123134

124135
}
125-
else if (!service.includes('kafkametrics')){
126-
console.log("healthDataList:", JSON.stringify(healthDataList));
136+
else if (!service.includes('kafkametrics')){//all health data
137+
console.log("healthDataList in elseif:", JSON.stringify(healthDataList));
127138
// console.log("set health metrics:", JSON.stringify(healthMetrics));
128139
if(healthDataList && healthDataList.length >0){
129140
setMetricsPool(getMetrics('health',healthDataList));
130141
}
131-
else{
142+
else if(healthMetricsReady){
132143
setMetricsPool(healthMetrics);
133144
}
145+
else{
146+
return;
147+
}
134148

135149
}
136150
else{
137-
console.log("healthData in else:", healthDataList.length);
138-
console.log("eventData in else:", eventDataList.length);
151+
139152
if(healthDataList && healthDataList.length >0 && eventDataList && eventDataList.length >0){
140153
console.log("eventDataList:", eventDataList.length);
141154
console.log("healthDataList", healthDataList.length);
@@ -145,6 +158,7 @@ const TransferColumns = React.memo(() => {
145158
console.log("set concat metrics:", JSON.stringify(eventMetrics.concat(healthMetrics)));
146159
setMetricsPool(eventMetrics.concat(healthMetrics));
147160
}
161+
148162
console.log("here");
149163

150164

app/context/HealthContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const HealthContextProvider: React.FC = React.memo(({ children }) => {
2121

2222
function tryParseJSON(jsonString: any) {
2323
try {
24+
console.log("jsonString in HealthContext:", jsonString);
2425
const o = JSON.parse(jsonString);
2526
if (o && typeof o === 'object') {
2627
return o;

app/context/helpers.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,11 @@ export function getTime(timeList, currService, metric, category) {
113113
}
114114
});
115115
return res;
116-
}
116+
};
117+
export const useIsMount = () => {
118+
const isMountRef = useRef(true);
119+
useEffect(() => {
120+
isMountRef.current = false;
121+
}, []);
122+
return isMountRef.current;
123+
};

0 commit comments

Comments
 (0)