Skip to content

Commit

Permalink
Fix annotation_json endpoint (apache#5621)
Browse files Browse the repository at this point in the history
* fix annotation_json endpoint

* add time back

* set db to None

* change if condition

* remove prop

* add guard for to_dttm

* linting

(cherry picked from commit 85a6da1)
  • Loading branch information
hughhhh authored and mistercrunch committed Aug 18, 2018
1 parent c209d59 commit 5af209e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def query(self, query_obj):
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)
Expand Down
3 changes: 2 additions & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ def get_df_payload(self, query_obj=None):
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:
Expand Down

0 comments on commit 5af209e

Please sign in to comment.