mirror of https://github.com/apache/superset.git
Fix annotation_json endpoint (#5621)
* fix annotation_json endpoint * add time back * set db to None * change if condition * remove prop * add guard for to_dttm * linting
This commit is contained in:
parent
9f6ac0898e
commit
85a6da19ee
|
@ -47,8 +47,10 @@ class AnnotationDatasource(BaseDatasource):
|
|||
error_message = None
|
||||
qry = db.session.query(Annotation)
|
||||
qry = qry.filter(Annotation.layer_id == query_obj['filter'][0]['val'])
|
||||
qry = qry.filter(Annotation.start_dttm >= query_obj['from_dttm'])
|
||||
qry = qry.filter(Annotation.end_dttm <= query_obj['to_dttm'])
|
||||
if query_obj['from_dttm']:
|
||||
qry = qry.filter(Annotation.start_dttm >= query_obj['from_dttm'])
|
||||
if query_obj['to_dttm']:
|
||||
qry = qry.filter(Annotation.end_dttm <= query_obj['to_dttm'])
|
||||
status = QueryStatus.SUCCESS
|
||||
try:
|
||||
df = pd.read_sql_query(qry.statement, db.engine)
|
||||
|
|
|
@ -379,7 +379,8 @@ class BaseViz(object):
|
|||
if query_obj and not is_loaded:
|
||||
try:
|
||||
df = self.get_df(query_obj)
|
||||
if hasattr(self.datasource.database, 'db_engine_spec'):
|
||||
if hasattr(self.datasource, 'database') and \
|
||||
hasattr(self.datasource.database, 'db_engine_spec'):
|
||||
db_engine_spec = self.datasource.database.db_engine_spec
|
||||
df = db_engine_spec.adjust_df_column_names(df, self.form_data)
|
||||
if self.status != utils.QueryStatus.FAILED:
|
||||
|
|
Loading…
Reference in New Issue