Skip to content

Commit

Permalink
[fix] Time filter: Add padding if min/max values are the same (UN-245…
Browse files Browse the repository at this point in the history
…8) (#409) (#2011)

Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>
Co-authored-by: Marko Letic <mletic@users.noreply.github.com>
  • Loading branch information
igorDykhta and mletic authored Nov 22, 2022
1 parent 3665738 commit 1214bd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/utils/src/filter-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,10 @@ export function getTimestampFieldDomain(
let step = 0.01;

const diff = domain[1] - domain[0];
// in case equal timestamp add 1 second padding to prevent break
if (!diff) {
domain[1] = domain[0] + 1000;
}
const entry = TimestampStepMap.find(f => f.max >= diff);
if (entry) {
step = entry.step;
Expand Down
2 changes: 1 addition & 1 deletion test/node/utils/filter-utils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ test('filterUtils -> getTimestampFieldDomain', t => {
zero: {
input: ['2016-10-01 09:45:39', '2016-10-01 09:45:39'],
expect: {
domain: [1475315139000, 1475315139000],
domain: [1475315139000, 1475315140000],
mappedValue: [1475315139000, 1475315139000],
histogram: [{count: 2, x0: 1475315139000, x1: 1475315139000}],
enlargedHistogram: [{count: 2, x0: 1475315139000, x1: 1475315139000}],
Expand Down

0 comments on commit 1214bd9

Please sign in to comment.