superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: Time filter fixes (#5448)
Date Fri, 20 Jul 2018 22:15:35 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 83e1e2c  Time filter fixes (#5448)
83e1e2c is described below

commit 83e1e2c0fe738e6134b2c30879bcd35698bb9112
Author: Beto Dealmeida <roberto@dealmeida.net>
AuthorDate: Fri Jul 20 15:15:33 2018 -0700

    Time filter fixes (#5448)
    
    * Fixes for the new time filter
    
    * Fix dashboard
    
    * Trigger tests
---
 .../assets/src/explore/components/controls/DateFilterControl.jsx | 1 +
 superset/data/__init__.py                                        | 1 +
 superset/utils.py                                                | 9 +++++++--
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/superset/assets/src/explore/components/controls/DateFilterControl.jsx b/superset/assets/src/explore/components/controls/DateFilterControl.jsx
index f15e6f4..b571a16 100644
--- a/superset/assets/src/explore/components/controls/DateFilterControl.jsx
+++ b/superset/assets/src/explore/components/controls/DateFilterControl.jsx
@@ -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'];
 
diff --git a/superset/data/__init__.py b/superset/data/__init__.py
index 5334269..5b3f151 100644
--- a/superset/data/__init__.py
+++ b/superset/data/__init__.py
@@ -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",
diff --git a/superset/utils.py b/superset/utils.py
index 76e2749..8fd8337 100644
--- a/superset/utils.py
+++ b/superset/utils.py
@@ -861,10 +861,12 @@ 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
 
@@ -872,9 +874,10 @@ def get_since_until(form_data):
     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':


Mime
View raw message