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

Time filter fixes #5448

Merged
merged 3 commits into from
Jul 20, 2018
Merged
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
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ const COMMON_TIME_FRAMES = [
'Last month',
'Last quarter',
'Last year',
'No filter',
];
const TIME_GRAIN_OPTIONS = ['seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years'];

1 change: 1 addition & 0 deletions superset/data/__init__.py
Original file line number Diff line number Diff line change
@@ -197,6 +197,7 @@ def load_world_bank_health_n_pop():
"row_limit": config.get("ROW_LIMIT"),
"since": "2014-01-01",
"until": "2014-01-02",
"time_range": "2014-01-01 : 2014-01-02",
"where": "",
"markup_type": "markdown",
"country_fieldtype": "cca3",
9 changes: 7 additions & 2 deletions superset/utils.py
Original file line number Diff line number Diff line change
@@ -861,20 +861,23 @@ def get_since_until(form_data):

Additionally, for `time_range` (these specify both `since` and `until`):

- Yesterday
- Last day
- Last week
- Last month
- Last quarter
- Last year
- No filter
- Last X seconds/minutes/hours/days/weeks/months/years
- Next X seconds/minutes/hours/days/weeks/months/years

"""
separator = ' : '
today = parse_human_datetime('today')
common_time_frames = {
'Yesterday': (today - relativedelta(days=1), today),
'Last day': (today - relativedelta(days=1), today),
'Last week': (today - relativedelta(weeks=1), today),
'Last month': (today - relativedelta(months=1), today),
'Last quarter': (today - relativedelta(months=3), today),
'Last year': (today - relativedelta(years=1), today),
}

@@ -886,6 +889,8 @@ def get_since_until(form_data):
until = parse_human_datetime(until)
elif time_range in common_time_frames:
since, until = common_time_frames[time_range]
elif time_range == 'No filter':
since = until = None
else:
rel, num, grain = time_range.split()
if rel == 'Last':