Skip to content

Commit

Permalink
fix(priceRanges): Remove round from first range
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiloc committed Nov 18, 2015
1 parent 885b72d commit bf82395
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/widgets/price-ranges/__tests__/generate-ranges-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import generateRanges from '../generate-ranges';
describe('generateRanges()', () => {
it('should generate ranges', () => {
let stats = {
min: 1.99,
min: 1.01,
max: 4999.98,
avg: 243.349,
sum: 2433490.0
};
let expected = [
{to: 1},
{from: 1, to: 80},
{to: 2},
{from: 2, to: 80},
{from: 80, to: 160},
{from: 160, to: 240},
{from: 240, to: 1820},
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/price-ranges/generate-ranges.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ function generateRanges(stats) {
let from;
let facetValues = [];
if (min !== max) {
next = round(min, precision);
next = min;

facetValues.push({
to: next
});

while (next < avg) {
from = facetValues[facetValues.length - 1].to;
next = round(from + (avg - min) / 3, precision);
Expand Down

0 comments on commit bf82395

Please sign in to comment.