Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add century and millenium to date aggregation #2162

Merged
merged 2 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/dataviews/helpers/histogram-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ var AGGREGATION_DATA = {
month: { unit: 'month', factor: 1 },
quarter: { unit: 'month', factor: 3 },
year: { unit: 'month', factor: 12 },
decade: { unit: 'month', factor: 120 }
decade: { unit: 'month', factor: 120 },
century: { unit: 'month', factor: 1200 },
millenium: { unit: 'month', factor: 12000 }
};

var helper = {};
Expand Down
15 changes: 15 additions & 0 deletions test/spec/dataviews/helpers/histogram-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ describe('dataview/helpers/histogram-helper', function () {
var expected = 170107634;
expect(actual).toBe(expected);
});
it('should add decades properly', function () {
var actual = helper.add(12341234, 4, 'century');
var expected = 12635122034;
expect(actual).toBe(expected);
});
it('should add centuries properly', function () {
var actual = helper.add(12341234, 5, 'century');
var expected = 15790882034;
expect(actual).toBe(expected);
});
it('should add milleniums properly', function () {
var actual = helper.add(12341234, 2, 'millenium');
var expected = 63126245234;
expect(actual).toBe(expected);
});
it('should throw an error for a wrong aggregation', function () {
expect(function () {
helper.add(12341234, 1, 'wrong');
Expand Down