john-bodley commented on a change in pull request #10079:
URL:
https://github.com/apache/incubator-superset/pull/10079#discussion_r441280997
##########
File path: superset/views/core.py
##########
@@ -2658,25 +2658,26 @@ def fetch_datasource_metadata(self) -> FlaskResponse:
return json_success(json.dumps(datasource.data))
@has_access_api
- @expose("/queries/<last_updated_ms>")
- def queries(self, last_updated_ms: str) -> FlaskResponse:
+ @expose("/queries/<float:last_updated_ms>")
+ @expose("/queries/<int:last_updated_ms>")
+ def queries(self, last_updated_ms: Union[float, int]) -> FlaskResponse:
"""
Get the updated queries.
- :param last_updated_ms: unix time, milliseconds
+ :param last_updated_ms: Unix time (milliseconds)
"""
- last_updated_ms_int = int(float(last_updated_ms)) if last_updated_ms
else 0
- return self.queries_exec(last_updated_ms_int)
- def queries_exec(self, last_updated_ms: int) -> FlaskResponse:
+ return self.queries_exec(last_updated_ms)
+
+ def queries_exec(self, last_updated_ms: Union[float, int]) ->
FlaskResponse:
stats_logger.incr("queries")
if not g.user.get_id():
return json_error_response(
"Please login to access the queries.", status=403
)
# UTC date time, same that is stored in the DB.
- last_updated_dt = utils.EPOCH + timedelta(seconds=last_updated_ms /
1000)
+ last_updated_dt = datetime.utcfromtimestamp(last_updated_ms / 1000)
Review comment:
Leveraging the native `datetime` logic for converting unix time to a
`datetime` object seems clearer/safer than adding a time delta to 1970-01-01.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]