Skip to content

Commit 9e8e95d

Browse files
jcpoirier20beezoo10jeffreyNa
committed
Added comments, removed redundant variables.
Co-authored-by: beezoo10 <[email protected]> Co-authored-by: jeffreyNa <[email protected]>
1 parent 9699235 commit 9e8e95d

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

app/containers/GraphsContainer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ const GraphsContainer: React.FC = React.memo(props => {
156156
};
157157

158158
const HealthAndEventButtons: JSX.Element[] = getHealthAndEventComponents();
159-
console.log({GraphsContainer: selectedMetrics})
160-
console.log({GraphsContainer: chart});
159+
console.log('selected metrics: ', {GraphsContainer: selectedMetrics})
160+
console.log('chart: ', { GraphsContainer: chart });
161+
161162
return (
162163
<>
163164
<nav id="navigationBar">

app/containers/HealthContainer.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,25 @@ const HealthContainer: React.FC<HealthContainerProps> = React.memo(props => {
4444

4545
datalist.forEach((element: {}) => {
4646
const categoryName: string = Object.keys(element)[0];
47-
// 'element' is the category found in the datalist response from the server query for metrics data
48-
// the above forEach method loops through the different categories
49-
// 'category' variable is the specific category passed in to HealthContainer via prop drilling
50-
// 'category' is the string Memory, CPU, or others that are in the Category column of the Query Selector interface
51-
// 'categoryName' is the string that is Memory/CPU/other inside the metrics data response ('datalist' or 'timelist')
52-
// when the 'element'/'categoryName' matches the 'category' selected in the Query Selection interface...
53-
// ... it will dive into that Category object to pull out a chart for each metric selected in the selection interface
54-
// selectedMetricsList is derived from the selectedMetrics that were in the QueryContext
55-
// selectedMetricsList is how we know which metrics should be made into a chart
56-
// selectedMetricsList is the way we can give one chart the multiple metrics being requested
47+
/*
48+
'element' is the category found in the datalist response from the server query for metrics data.
49+
The above forEach method loops through the different categories.
50+
The 'category' variable is the specific category passed in to HealthContainer via prop drilling.
51+
The 'category' is the string Memory, CPU, or others that are in the Category column of the Query Selector interface.
52+
The 'categoryName' is the string that is Memory/CPU/other inside the metrics data response ('datalist' or 'timelist').
53+
When the 'element'/'categoryName' matches the 'category' selected in the Query Selection interface...
54+
... it will dive into that Category object to pull out a chart for each metric selected in the selection interface.
55+
selectedMetricsList is derived from the selectedMetrics that were in the QueryContext.
56+
selectedMetricsList is how we know which metrics should be made into a chart.
57+
selectedMetricsList is the way we can give one chart the multiple metrics being requested.
58+
*/
5759
if (category === categoryName) {
5860
const categoryObj: [] = element[categoryName];
5961
for (const metricObj of categoryObj) {
6062
const serviceName: string = Object.keys(metricObj)[0];
61-
const serviceValArr: any[] = Object.values(metricObj);
62-
const serviceVals: any[] = serviceValArr[0];
63-
for (const serviceMetric of serviceVals) {
63+
const serviceMetricsArr: any[] = Object.values(metricObj).flat();
64+
console.log('serviceMetricsArr: ', serviceMetricsArr); // -> array of objects.
65+
for (const serviceMetric of serviceMetricsArr) {
6466
const metric: string = Object.keys(serviceMetric)[0];
6567
const valueList = Object.values(serviceMetric)[0];
6668
const newTimeList: any = getTime(timelist, serviceName, metric, categoryName);

0 commit comments

Comments
 (0)