-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix annotation_json endpoint #5621
Conversation
…x_annotations_json
@@ -47,8 +47,6 @@ 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']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hughhhh, why do you need to remove this? I'm worried it might bring too many annotations to the browser if we remove this — it would bring all holidays, instead of only the ones being displayed, eg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about:
if query_obj['from_dttm']:
qry = qry.filter(Annotation.start_dttm >= query_obj['from_dttm'])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at the annotations_json
endpoint we don't set the from_dttm
or to_dttm
at all. I just wanted to fix this endpoint to actually work because on master its not working at all.
https://github.com/apache/incubator-superset/blob/master/superset/views/core.py#L1118
superset/viz.py
Outdated
df = db_engine_spec.adjust_df_column_names(df, self.form_data) | ||
if self.status != utils.QueryStatus.FAILED: | ||
stats_logger.incr('loaded_from_source') | ||
is_loaded = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: why is this broken? I'm worried changing this will break existing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this looks dangerous, the hasattr
condition seems to be for preventing druid-related exception (a condition on that would be more explicit here). I'm pretty sure it's there for a reason.
I added that. It's there to check whether the datasource is sqla or not. Apparently the check needs to be for datasource.database, not datasource.database.db_engine_spec. |
superset/connectors/sqla/models.py
Outdated
@@ -47,7 +47,8 @@ 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']) | |||
if query_obj['from_dttm']: | |||
qry = qry.filter(Annotation.start_dttm >= query_obj['from_dttm']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh we need to same for to_dttm
I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_dttm
is set to the current date in the query object. I can add the guard though 👍
@hughhhh To add some context, |
@villebro I think the check is fine. The problem is that the AnnotationsDatasource object is missing fields and is basically buffer to leverage the |
I'll go with your approach |
Codecov Report
@@ Coverage Diff @@
## master #5621 +/- ##
==========================================
+ Coverage 63.48% 63.73% +0.24%
==========================================
Files 360 360
Lines 22886 23113 +227
Branches 2547 2548 +1
==========================================
+ Hits 14529 14730 +201
- Misses 8342 8368 +26
Partials 15 15
Continue to review full report at Codecov.
|
LGTM |
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* 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)
* fix annotation_json endpoint * add time back * set db to None * change if condition * remove prop * add guard for to_dttm * linting
Current implementation of
/annotations_json/{layerId}
is broken. Simplified the endpoint to filter based upon the layer.@betodealmeida @mistercrunch