Fix: Lint docker stats throughput PR

pull/2336/head
shamoon 1 year ago
parent 7f50f6cfaa
commit 6316de6fa6

@ -41,7 +41,7 @@ export default function Component({ service }) {
);
}
const { rx_bytes, tx_bytes } = calculateThroughput(statsData.stats);
const { rxBytes, txBytes } = calculateThroughput(statsData.stats);
return (
<Container service={service}>
@ -51,8 +51,8 @@ export default function Component({ service }) {
)}
{statsData.stats.networks && (
<>
<Block label="docker.rx" value={t("common.bytes", { value: rx_bytes })} />
<Block label="docker.tx" value={t("common.bytes", { value: tx_bytes })} />
<Block label="docker.rx" value={t("common.bytes", { value: rxBytes })} />
<Block label="docker.tx" value={t("common.bytes", { value: txBytes })} />
</>
)}
</Container>

@ -18,16 +18,16 @@ export function calculateUsedMemory(stats) {
}
export function calculateThroughput(stats) {
let rx_bytes = 0;
let tx_bytes = 0;
let rxBytes = 0;
let txBytes = 0;
if (stats.networks?.network) {
rx_bytes = stats.networks?.network.rx_bytes;
tx_bytes = stats.networks?.network.tx_bytes;
rxBytes = stats.networks?.network.rx_bytes;
txBytes = stats.networks?.network.tx_bytes;
} else if (stats.networks && Array.isArray(Object.values(stats.networks))) {
Object.values(stats.networks).forEach((containerInterface) => {
rx_bytes += containerInterface.rx_bytes;
tx_bytes += containerInterface.tx_bytes;
rxBytes += containerInterface.rx_bytes;
txBytes += containerInterface.tx_bytes;
});
}
return { rx_bytes, tx_bytes };
return { rxBytes, txBytes };
}

Loading…
Cancel
Save