Skip to content

Commit

Permalink
[filter_box] Fix show time column in filter_box (apache#8740)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace Guo authored Dec 4, 2019
1 parent b0b9376 commit 8995044
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import getFilterConfigsFromFormdata from '../../../../src/dashboard/util/getFilterConfigsFromFormdata';

describe('getFilterConfigsFromFormdata', () => {
const testFormdata = {
date_filter: true,
granularity_sqla: '__time',
time_grain_sqla: 'P1M',
time_range: '2018-12-30T00:00:00+:+last+saturday',
};

it('should add time grain', () => {
const result = getFilterConfigsFromFormdata({
...testFormdata,
show_sqla_time_granularity: true,
});
expect(result.columns).toMatchObject({
__time_grain: testFormdata.time_grain_sqla,
});
});

it('should add time column', () => {
const result = getFilterConfigsFromFormdata({
...testFormdata,
show_sqla_time_column: true,
});
expect(result.columns).toMatchObject({
__time_col: testFormdata.granularity_sqla,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ export default function getFilterConfigsFromFormdata(form_data = {}) {
[TIME_FILTER_MAP.time_range]: FILTER_LABELS[TIME_RANGE],
};

if (show_sqla_time_column) {
if (show_sqla_time_granularity) {
updatedColumns = {
...updatedColumns,
[TIME_FILTER_MAP.time_grain_sqla]: form_data.time_grain_sqla,
};
}

if (show_sqla_time_granularity) {
if (show_sqla_time_column) {
updatedColumns = {
...updatedColumns,
[TIME_FILTER_MAP.granularity_sqla]: form_data.granularity_sqla,
Expand Down

0 comments on commit 8995044

Please sign in to comment.