Quantcast
Channel: Feature Suggestions
Viewing all articles
Browse latest Browse all 25

Bytes formatter unit size setting

$
0
0

@theyosh wrote:

We are using the Download (https://github.com/piwik/plugin-Bandwidth) module for showing downloaded traffic. But we see that the formatter uses a factor 1024 for translating bytes to Megabytes and Terabytes.

But we would like to use the factor 1000. Because we have another tool for calculating the used bandwidth, and there the units factor is 1000. So at this time we have a difference.

If this could be a setting in the config.ini.php file so we can override this value.

The function that should read this setting is:
core/Metrics/Formatter.php
in the function:


protected function getPrettySizeFromBytesWithUnit($size, $unit = null, $precision = 1)
    {
        $units = array('B', 'K', 'M', 'G', 'T');
        $numUnits = count($units) - 1;

        $currentUnit = null;
        foreach ($units as $idx => $currentUnit) {
            if ($unit && $unit !== $currentUnit) {
                $size = $size / 1024;
            } elseif ($unit && $unit === $currentUnit) {
                break;
            } elseif ($size >= 1024 && $idx != $numUnits) {
                $size = $size / 1024;
            } else {
                break;
            }
        }

        $size = round($size, $precision);

        return array($size, $currentUnit);
    }

Could this be implemented in a next release? Would be nice

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 25

Trending Articles