michellethomas commented on a change in pull request #6269: Fixing time range 
since with no "ago"
URL: 
https://github.com/apache/incubator-superset/pull/6269#discussion_r230896332
 
 

 ##########
 File path: superset/utils/core.py
 ##########
 @@ -923,6 +923,15 @@ def get_since_until(form_data):
         time_range = form_data['time_range']
         if separator in time_range:
             since, until = time_range.split(separator, 1)
+            # Backward compatibility hack
+            if since and since not in common_time_frames:
+                since_words = since.split(' ')
+                grains = ['days', 'years', 'hours', 'day', 'year', 'weeks']
+                if (len(since_words) == 2 and since_words[1] in grains):
+                    since += ' ago'
+            # Handling 'No filter' default getting added as since
+            if since == 'No filter':
+                since = None
 
 Review comment:
   I think we only need to check since because of the way time_range is getting 
split up 
[here](https://github.com/apache/incubator-superset/pull/6269/files#diff-ac978615a4f22c4fad4d01f39e1d4595R1044).
 Only since would get set to 'No filter' and until would be None. I think 
there's a case where since could be 'No filter' and until could be set to a 
value we want to keep around. If until is set and since is not in form_data, 
and slice_form_data uses time_range 'No filter', the slice_form_data would get 
split into `since: 'No filter', until: None` but the 'until' from form_data 
would overwrite None so the end result could be `since: 'No filter', until: 
'Some date'`. It's pretty handling these edge cases so we should clean this 
logic up. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to