Fix sorting order on home page
This commit fixes the sorting order on the home page. We should have a floating point value rounded to 4 digits after the decimal point at least. For example, 0.3333 would be 33% with the original rounding. However, this is not enough resolution for the home page. This should be 33.33% at least. Closes-Bug: #1522200 Change-Id: I2e57fce318256fcd6e9aee892706d21d5269b81c
This commit is contained in:
parent
b7a30358f0
commit
21eca6c9bb
@ -15,7 +15,7 @@ var metricsService = function() {
|
|||||||
|
|
||||||
service.getFailRate = function(metrics) {
|
service.getFailRate = function(metrics) {
|
||||||
var failRate = metrics.failures / (metrics.passes + metrics.failures) || 0;
|
var failRate = metrics.failures / (metrics.passes + metrics.failures) || 0;
|
||||||
return Math.round(failRate * 100) / 100;
|
return Math.round(failRate * 10000) / 10000;
|
||||||
};
|
};
|
||||||
|
|
||||||
service.addMetrics = function(metrics1, metrics2) {
|
service.addMetrics = function(metrics1, metrics2) {
|
||||||
|
@ -22,8 +22,8 @@ describe('MetricService', function() {
|
|||||||
var objects = [
|
var objects = [
|
||||||
{ metrics: { passes: 0, failures: 0 }, expectedFailRate: 0 },
|
{ metrics: { passes: 0, failures: 0 }, expectedFailRate: 0 },
|
||||||
{ metrics: { passes: 0, failures: 1 }, expectedFailRate: 1 },
|
{ metrics: { passes: 0, failures: 1 }, expectedFailRate: 1 },
|
||||||
{ metrics: { passes: 2, failures: 1 }, expectedFailRate: 0.33 },
|
{ metrics: { passes: 2, failures: 1 }, expectedFailRate: 0.3333 },
|
||||||
{ metrics: { passes: 1, failures: 2 }, expectedFailRate: 0.67 },
|
{ metrics: { passes: 1, failures: 2 }, expectedFailRate: 0.6667 },
|
||||||
{ metrics: { passes: 1, failures: 3 }, expectedFailRate: 0.75 }
|
{ metrics: { passes: 1, failures: 3 }, expectedFailRate: 0.75 }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user