This is an automated email from the ASF dual-hosted git repository. johnbodley 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 eba1fe2 fix: Ensuring queries route accepts float or int (#10079) eba1fe2 is described below commit eba1fe2ebb45a7a27d547a268c8097703e01b5b1 Author: John Bodley <4567245+john-bod...@users.noreply.github.com> AuthorDate: Wed Jun 17 08:02:49 2020 -0700 fix: Ensuring queries route accepts float or int (#10079) Co-authored-by: John Bodley <john.bod...@airbnb.com> --- superset/views/core.py | 15 ++++++++------- tests/sqllab_tests.py | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/superset/views/core.py b/superset/views/core.py index e173972..ad0343c 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -2658,17 +2658,18 @@ class Superset(BaseSupersetView): 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( @@ -2676,7 +2677,7 @@ class Superset(BaseSupersetView): ) # 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) sql_queries = ( db.session.query(Query) diff --git a/tests/sqllab_tests.py b/tests/sqllab_tests.py index e88c1b0..7c1b0e6 100644 --- a/tests/sqllab_tests.py +++ b/tests/sqllab_tests.py @@ -192,6 +192,8 @@ class SqlLabTests(SupersetTestCase): self.login("admin") data = self.get_json_resp("/superset/queries/0") self.assertEqual(2, len(data)) + data = self.get_json_resp("/superset/queries/0.0") + self.assertEqual(2, len(data)) # Run 2 more queries self.run_sql("SELECT * FROM birth_names LIMIT 1", client_id="client_id_4")