Skip to content
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: filter_values in jinja_context not processing adhoc_filters #9348

Closed
wants to merge 4 commits into from
Closed

fix: filter_values in jinja_context not processing adhoc_filters #9348

wants to merge 4 commits into from

Conversation

villebro
Copy link
Member

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

Currently the filter_values function in jinja_context.py is not able to process adhoc_filters when a chart is rendered in the Explore View. This PR moves filter preprocessing logic from viz.py into utlis/core.py and applies said logic to form_data in the Jinja context.

TEST PLAN

Local testing + new and old tests

ADDITIONAL INFORMATION

REVIEWERS

@sahiljain001 @lilila

@codecov-io
Copy link

Codecov Report

Merging #9348 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9348   +/-   ##
=======================================
  Coverage   58.96%   58.96%           
=======================================
  Files         374      374           
  Lines       12137    12137           
  Branches     2992     2992           
=======================================
  Hits         7156     7156           
  Misses       4802     4802           
  Partials      179      179           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5e6662a...b1e66d3. Read the comment docs.

return_val.append(v)
else:
return_val.append(f["val"])
for f in form_data.get("filters", {}):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was working on filters recently and I'm pretty sure these are now under adhoc_filters

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wan't completely familiar territory to me, so I might be wrong here. But currently process_query_filters() in viz..py, which is the first thing query_obj() calls, goes through a long step of transformations that first changes everything into adhoc_filters, and finally changes those to regular filters. I'm unsure why this happens, but my takeaway was that if process_query_filters is run, you are left with nothing but filters, despite how they started out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow. This is confusing. Looks like you looked into it deeper than I have. 👍

Copy link
Member Author

@villebro villebro Mar 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably something for the refactor backlog. I took another pass at how this works in practice, and these are my takeaways:

Anyway, in the short term, I think this fix is the right solution.

@lilila
Copy link

lilila commented Mar 24, 2020

WOW , it works very well. Thank you @villebro <3

@lilila
Copy link

lilila commented Mar 25, 2020

This is a great improvement, thank you again.
Just a comment @villebro , if I display a plot in a an iFrame (using the html code provided in the iframe tab in the explore chart page) I have a message ("Action required: Preview ....") which appears every time the plot is loaded as shown in the pic bellow

Screenshot 2020-03-25 at 12 41 16

@villebro
Copy link
Member Author

@lilila I assume this is on the Public role?

@villebro
Copy link
Member Author

@mistercrunch is this ok to merge?

@lilila
Copy link

lilila commented Mar 26, 2020

Yes @villebro it is on public role.
Do you know how to preserve label_colors when displayed in "standalone" mode?
When standalone is not set to true, the plot has the colors defined in the dashboard, but unfortunately the standard airbnb colors come back when standalone is set to true. (However, I notice all labels colors are sent in the URL)

Thank you for your help

@villebro
Copy link
Member Author

@lilila I expect these are bugs that surface due to the Public role which isn't as frequently used as the regular ones. Would you mind opening issues for these, preferably one per problem? It will make it easier to identify and fix the bugs. Thanks!

@lilila
Copy link

lilila commented Mar 26, 2020

I'll do this

@villebro
Copy link
Member Author

I'm closing this in favor of #9582 .

@villebro villebro closed this Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants