xtinec commented on a change in pull request #6220: [SIP-5] Open a new
/api/v1/query endpoint that takes query_obj
URL:
https://github.com/apache/incubator-superset/pull/6220#discussion_r231713571
##########
File path: superset/utils/core.py
##########
@@ -940,15 +940,20 @@ def get_since_until(form_data):
since = today
until = today + relativedelta(**{grain: int(num)})
else:
- since = form_data.get('since', '')
+ since = since or ''
if since:
since = add_ago_to_since(since)
since = parse_human_datetime(since)
- until = parse_human_datetime(form_data.get('until', 'now'))
+ until = parse_human_datetime(until or 'now')
return since, until
+def assert_from_to_dttm(from_dttm, to_dttm):
Review comment:
Moving them to all to utils and adding types. I quite like it now. 😄
```
if time_shift:
time_shift = parse_human_timedelta(time_shift)
since = since if since is None else (since - time_shift)
until = until if until is None else (until - time_shift)
if since and until and since > until:
raise ValueError(_('From date cannot be larger than to date'))
return since, until
```
Then, in the constructor, we simply have
```
self.from_dttm, self.to_dttm = utils.get_since_until(time_range, time_shift)
```
Updates coming shortly.
----------------------------------------------------------------
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]