mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
refactor sql_json view endpoint: extract to method reuse code (#16546)
This commit is contained in:
parent
80c39daa85
commit
e947f8a4c8
@ -2411,8 +2411,9 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||||||
return json_error_response(f"{msg}", status=400)
|
return json_error_response(f"{msg}", status=400)
|
||||||
return json_error_response(f"{msg}")
|
return json_error_response(f"{msg}")
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def _sql_json_async(
|
def _sql_json_async( # pylint: disable=too-many-arguments
|
||||||
|
cls,
|
||||||
session: Session,
|
session: Session,
|
||||||
rendered_query: str,
|
rendered_query: str,
|
||||||
query: Query,
|
query: Query,
|
||||||
@ -2474,19 +2475,13 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||||||
# Update saved query with execution info from the query execution
|
# Update saved query with execution info from the query execution
|
||||||
QueryDAO.update_saved_query_exec_info(query_id)
|
QueryDAO.update_saved_query_exec_info(query_id)
|
||||||
|
|
||||||
resp = json_success(
|
resp = json_success(cls._convert_query_to_payload(query), status=202,)
|
||||||
json.dumps(
|
|
||||||
{"query": query.to_dict()},
|
|
||||||
default=utils.json_int_dttm_ser,
|
|
||||||
ignore_nan=True,
|
|
||||||
),
|
|
||||||
status=202,
|
|
||||||
)
|
|
||||||
session.commit()
|
session.commit()
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
def _sql_json_sync(
|
def _sql_json_sync(
|
||||||
|
cls,
|
||||||
_session: Session,
|
_session: Session,
|
||||||
rendered_query: str,
|
rendered_query: str,
|
||||||
query: Query,
|
query: Query,
|
||||||
@ -2723,6 +2718,14 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||||||
session, rendered_query, query, expand_data, log_params
|
session, rendered_query, query, expand_data, log_params
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _convert_query_to_payload(query: Query) -> str:
|
||||||
|
return json.dumps(
|
||||||
|
{"query": query.to_dict()},
|
||||||
|
default=utils.json_int_dttm_ser,
|
||||||
|
ignore_nan=True,
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_the_query_db(
|
def _get_the_query_db(
|
||||||
cls, execution_context: SqlJsonExecutionContext, session: Session
|
cls, execution_context: SqlJsonExecutionContext, session: Session
|
||||||
|
Loading…
Reference in New Issue
Block a user