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_r231707248
 
 

 ##########
 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:
   What do you think of computing `from_dttm` and `to_dttm` and asserting their 
validity as part of `get_since_util` (i.e. moving the logic in the blob below 
into `get_since_util`). We'll provide time_shift as an additional argument to 
get_since_until. 
   ```
           self.from_dttm = None if since_dttm is None else (since_dttm - 
time_shift_dttm)
           self.to_dttm = None if until_dttm is None else (until_dttm - 
time_shift_dttm)
           utils.assert_from_to_dttm(self.from_dttm, self.to_dttm)
   ```
   
   My thought is all these time computation and validation should be 1) reused 
(it is not currently doesn't mean it can't be) and 2) kept out of the main 
constructor of `QueryObject` to make the constructor code easy to read.
   
   Otherwise, I'm happy to put the two lines back.

----------------------------------------------------------------
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