Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Added top consumer card for storage dashboard #349

Merged
merged 1 commit into from
Apr 15, 2019

Conversation

gnehapk
Copy link
Contributor

@gnehapk gnehapk commented Apr 12, 2019

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1184

  • 32 of 39 (82.05%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 87.211%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/components/StorageOverview/TopConsumers/TopConsumers.js 14 21 66.67%
Totals Coverage Status
Change from base Build 1181: -0.1%
Covered Lines: 3346
Relevant Lines: 3675

💛 - Coveralls

@coveralls
Copy link

coveralls commented Apr 12, 2019

Pull Request Test Coverage Report for Build 1230

  • 33 of 36 (91.67%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 87.352%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/components/StorageOverview/TopConsumers/TopConsumers.js 14 15 93.33%
src/utils/utils.js 1 3 33.33%
Totals Coverage Status
Change from base Build 1223: 0.02%
Covered Lines: 3378
Relevant Lines: 3707

💛 - Coveralls

@gnehapk
Copy link
Contributor Author

gnehapk commented Apr 12, 2019

@rawagner @mareklibra Please review

import { getTopConsumerVectorStats } from '../../../selectors';

const TopConsumersBody = ({ stats }) => {
let results = 'Not data available';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - should be No data available

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

export const getTopConsumerVectorStats = result => {
let maxVal = 0;

forEach(result, namespace => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not ES6 forEach ?

let largestLengthArrayIndex = 0;

// timestamps count and values are not same for all the namespaces. Hence, finding the largest length array and taking its timestamps value as x-axis point
forEach(result, (namespace, index) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not ES6 forEach ?

<Row>
<Col lg={12} md={12} sm={12} xs={12}>
<LineChart
className="kubevirt-top-consumers__body"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see this classname in any scss file

if (stats.length) {
const columnsConf = getTopConsumerVectorStats(stats);
const { columns, unit } = columnsConf;
const formatTime = x => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Date(x).toISOString().substring(11,16) is a bit simpler. Could you please put this into utils? And maybe rename it as formatToShortISOTime ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toISOString method will return the time in zero UTC time zone. Instead of that toString method can be used.

@@ -28,3 +28,40 @@ export const getLastUtilizationStat = response => {
const history = getUtilizationVectorStats(response);
return history ? history[history.length - 1] : null;
};

export const getTopConsumerVectorStats = result => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please move this to prometheus/storage.js ? it is getting overcrowded here IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

export const getTopConsumerVectorStats = result => {
let maxVal = 0;

result.forEach(namespace => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use map here instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think map can be used here. Map method creates a new array with the results of calling a provided function on every element in the calling array. Here, I don't want to create a new array after performing the required actions. I just want to iterate over the array in order to find the max element. Hence, used forEach.

let maxVal = 0;

result.forEach(namespace => {
namespace.values.forEach(value => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also use lodash flatMap here and have one Math.max call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, flatMap will be a better solution.

});
});

const maxCapacityConveretd = { ...formatBytes(maxVal) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@gnehapk gnehapk force-pushed the storage-top-consumer branch 2 times, most recently from 0fd9058 to 815f232 Compare April 14, 2019 12:49
@gnehapk
Copy link
Contributor Author

gnehapk commented Apr 14, 2019

Incorporated the review comments. @rawagner @mareklibra @suomiy Please review.

let flattenedResult = [];

// returns all the namespace.values in an array
flattenedResult = flatMap(result, namespace => namespace.values);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can name the variables accordingly and we might not need the comments
e.g.

namespaceValues =
allValues = // allBytes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@gnehapk
Copy link
Contributor Author

gnehapk commented Apr 15, 2019

Rebased the PR. @rawagner @suomiy Please review.

let namespaceValues = [];
let allBytes = [];

namespaceValues = flatMap(result, namespace => namespace.values);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be const

let allBytes = [];

namespaceValues = flatMap(result, namespace => namespace.values);
allBytes = flatMap(namespaceValues, value => parseNumber(value[1]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ here


.kubevirt-top-consumer__time-duration {
float: right;
padding-right: 17px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change to rem

@gnehapk
Copy link
Contributor Author

gnehapk commented Apr 15, 2019

@rawagner @suomiy Amended the PR. Please review.

@rawagner rawagner merged commit e59f281 into kubevirt:master Apr 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants