-
Notifications
You must be signed in to change notification settings - Fork 16.6k
fix(extra-filters): add logic for identifying applied extra filters #11325
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(extra-filters): add logic for identifying applied extra filters #11325
Conversation
* button translations missing * blank space before text
* feat: update time_compare description and choices * Update sections.jsx
| applied_time_extras = fields.Dict( | ||
| description="A mapping of temporal extras that have been applied to the query", | ||
| required=False, | ||
| example={"__time_range": "1 year ago : now"}, | ||
| ) |
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.
I tried creating a dedicated schema with named properties (__time_range etc) and then adding a nested reference here, but that didn't work, probably due to the double underscores. Leaving these as a fields.Dict for now to get around the double underscore problem.
| druid_time_origin = fields.String( | ||
| description="Starting point for time grain counting on legacy Druid " | ||
| "datasources. Used to change e.g. Monday/Sunday first-day-of-week. " | ||
| "This field is deprecated and should be passed to `extras` " | ||
| "as `druid_time_origin`.", | ||
| allow_none=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.
Turns out this was missing from the chart data schema. Also added to deprecated field mapping in query_object.py.
Codecov Report
@@ Coverage Diff @@
## feature/filter-p0 #11325 +/- ##
=====================================================
+ Coverage 60.78% 60.83% +0.04%
=====================================================
Files 393 393
Lines 24848 24900 +52
=====================================================
+ Hits 15105 15147 +42
- Misses 9743 9753 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
I'm unsure why GH is showing this line (and other similar ones) as changed, as I haven't touched them (the branch is based on apache:feature/filter-p0 and is up-to-date)
77b41f6 to
1d63d1c
Compare
| data = fields.List(fields.Dict(), description="A list with results") | ||
| applied_filters = fields.List( | ||
| fields.Dict(), description="A list with applied filters" | ||
| ) |
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.
I forgot to add this, thank you!
|
|
||
| def __repr__(self) -> str: | ||
| return f"Dashboard<{self.slug or self.id}>" | ||
| return f"Dashboard<{self.id or self.slug}>" |
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.
shouldn't this be the other way round? Is this one of those lines you didn't touch?
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.
I guess if it's for the __repr__ function it makes more sense to use the id
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.
I haven't changed these lines, I think this is GH acting up showing some changes that have come in after the branch was cut.
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.
Huh. Maybe you merged master or something
suddjian
left a comment
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.
Thanks Ville!
* Initial commit of new filters badge. * refactor applied/rejected filters code * finished filter indicators * filter badge tested * unnecessary imports * formatting and types * fixes * license * code quality tweaks * state management for showing focused filter scope * clean up filter key extraction code * remove unnecessary styles * temp css to demonstrate highlighting * fix focused filter logic * no more color badges * new toys for highlighting dash components (#11144) * tweak style for the filter chart when filter is focused * style: Filters p0 css2 (#11151) * nixing background tweak * src paths * another quick theme color * src paths, adjusting pill icon color, changing icons, showing applied/busted counts * linting stuff * fixing and tweaking tests * show filter indicator when filters are not active * chart title bar cleanup * open the right panel when popover opens * unused import * fix EditableTitle tests * margin on dashboard header * show the chart dropdown menu * fix blur filter breaking dropdowns * style tweak - no pointer events when irrelevant charts are blurred * fix box shadow on filter highlight * it's an array * attempt fixing e2e * style: filters p0 icon churn (#11215) * new filters icon * icon styling * bigger icons in list views * better sizing of table actions and favStars * more icon sizing... * fixing more button size jankiness * linting * Filters performance (#11255) * fixing time filter "ok" button * making unset filter menu collapsible * sort alphabetically * fix highlighting when removing items * try a flex layout (for browser render perf) * more specific transitioning * temp: comment out some code as a test * temp: comment out more code * temp: remove possibly expensive computations from ChartHolder * Revert "temp: comment out some code as a test" This reverts commit 309b880. * Revert "temp: comment out more code" This reverts commit 64c88b2. * Revert "temp: remove possibly expensive computations from ChartHolder" This reverts commit 37ce021. * experiment: upgrade react-select to v3 * Revert "experiment: upgrade react-select to v3" This reverts commit c3972ba. * fix the damn problem * remove code used for testing purposes * awful hack to avoid adding a class to a container * approaching infinity... and not beyond! * fix ref forwarding * add theme to tests as necessary * fix(extra-filters): add logic for identifying applied extra filters (#11325) * fix: use dashboard id for stable cache key (#11293) * fix: button translations missing (#11187) * button translations missing * blank space before text * feat: update time_compare description and choices (#11294) * feat: update time_compare description and choices * Update sections.jsx * fix(extra-filters): add logic for identifying applied extra filters * lint Co-authored-by: Jesse Yang <[email protected]> Co-authored-by: rubenSastre <[email protected]> Co-authored-by: Erik Ritter <[email protected]> * address design feedback * slight tweak to panel logic, keep panels open that user has opened * rearrange code to be more graceful * fix: bump superset-ui/core (#11385) * use is_dttm instead of is_temporal * types, names * only show unset filter panel if there are unset filters * fix highlighting the filter control * fix filterbox layout * translations * fix cypress * actually add the test attribute * Update superset-frontend/src/dashboard/components/DashboardBuilder.jsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/DashboardBuilder.jsx Co-authored-by: Evan Rusackas <[email protected]> * formatting * add link comment to hack * Update superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx Co-authored-by: Evan Rusackas <[email protected]> * stop importing lodash * Update superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * skip broken test * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * adjust colors of titles * linting * no indicators when chart is loading * support all time fields * fix lock file Co-authored-by: Natalie Ruhe <[email protected]> Co-authored-by: Evan Rusackas <[email protected]> Co-authored-by: Ville Brofeldt <[email protected]> Co-authored-by: Jesse Yang <[email protected]> Co-authored-by: rubenSastre <[email protected]> Co-authored-by: Erik Ritter <[email protected]> Co-authored-by: Ville Brofeldt <[email protected]>
* Initial commit of new filters badge. * refactor applied/rejected filters code * finished filter indicators * filter badge tested * unnecessary imports * formatting and types * fixes * license * code quality tweaks * state management for showing focused filter scope * clean up filter key extraction code * remove unnecessary styles * temp css to demonstrate highlighting * fix focused filter logic * no more color badges * new toys for highlighting dash components (apache#11144) * tweak style for the filter chart when filter is focused * style: Filters p0 css2 (apache#11151) * nixing background tweak * src paths * another quick theme color * src paths, adjusting pill icon color, changing icons, showing applied/busted counts * linting stuff * fixing and tweaking tests * show filter indicator when filters are not active * chart title bar cleanup * open the right panel when popover opens * unused import * fix EditableTitle tests * margin on dashboard header * show the chart dropdown menu * fix blur filter breaking dropdowns * style tweak - no pointer events when irrelevant charts are blurred * fix box shadow on filter highlight * it's an array * attempt fixing e2e * style: filters p0 icon churn (apache#11215) * new filters icon * icon styling * bigger icons in list views * better sizing of table actions and favStars * more icon sizing... * fixing more button size jankiness * linting * Filters performance (apache#11255) * fixing time filter "ok" button * making unset filter menu collapsible * sort alphabetically * fix highlighting when removing items * try a flex layout (for browser render perf) * more specific transitioning * temp: comment out some code as a test * temp: comment out more code * temp: remove possibly expensive computations from ChartHolder * Revert "temp: comment out some code as a test" This reverts commit 309b880. * Revert "temp: comment out more code" This reverts commit 64c88b2. * Revert "temp: remove possibly expensive computations from ChartHolder" This reverts commit 37ce021. * experiment: upgrade react-select to v3 * Revert "experiment: upgrade react-select to v3" This reverts commit c3972ba. * fix the damn problem * remove code used for testing purposes * awful hack to avoid adding a class to a container * approaching infinity... and not beyond! * fix ref forwarding * add theme to tests as necessary * fix(extra-filters): add logic for identifying applied extra filters (apache#11325) * fix: use dashboard id for stable cache key (apache#11293) * fix: button translations missing (apache#11187) * button translations missing * blank space before text * feat: update time_compare description and choices (apache#11294) * feat: update time_compare description and choices * Update sections.jsx * fix(extra-filters): add logic for identifying applied extra filters * lint Co-authored-by: Jesse Yang <[email protected]> Co-authored-by: rubenSastre <[email protected]> Co-authored-by: Erik Ritter <[email protected]> * address design feedback * slight tweak to panel logic, keep panels open that user has opened * rearrange code to be more graceful * fix: bump superset-ui/core (apache#11385) * use is_dttm instead of is_temporal * types, names * only show unset filter panel if there are unset filters * fix highlighting the filter control * fix filterbox layout * translations * fix cypress * actually add the test attribute * Update superset-frontend/src/dashboard/components/DashboardBuilder.jsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/DashboardBuilder.jsx Co-authored-by: Evan Rusackas <[email protected]> * formatting * add link comment to hack * Update superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx Co-authored-by: Evan Rusackas <[email protected]> * stop importing lodash * Update superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * skip broken test * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * Update superset-frontend/src/dashboard/components/FiltersBadge/Styles.tsx Co-authored-by: Evan Rusackas <[email protected]> * adjust colors of titles * linting * no indicators when chart is loading * support all time fields * fix lock file Co-authored-by: Natalie Ruhe <[email protected]> Co-authored-by: Evan Rusackas <[email protected]> Co-authored-by: Ville Brofeldt <[email protected]> Co-authored-by: Jesse Yang <[email protected]> Co-authored-by: rubenSastre <[email protected]> Co-authored-by: Erik Ritter <[email protected]> Co-authored-by: Ville Brofeldt <[email protected]>
SUMMARY
Adds support for
applied_filtersandrejected_filtersto chart data endpoint + adds support for temporal extras to bothviz.pyand chart data endpoint.Short summary of changes:
json_exploreendpoint, temporal extras (__time_rangeetc) are applied toform_datainmerge_extras(see: https://github.com/apache/incubator-superset/blob/735123d1f5513d366955db1865faf6b064c9bd4a/superset/utils/core.py#L922-L953 ), information of which temporal filters have been overridden is lost. To get around this, we add the applied temporal extras in a dict calledapplied_time_extrasthat we can later reference to determine which of them were applied and which were not.superset-ui/coremerges temporal extras to the query object prior to sending the request, essentially performing the above operation (see: https://github.com/apache-superset/superset-ui/blob/master/packages/superset-ui-core/src/query/extractExtras.ts) , we need to pass alongapplied_time_extrasin the request.Please note: needs to upgrade to new version of
superset-ui/coreintroduced here to function properly with v1 API plugins: apache-superset/superset-ui#809 .SCREENSHOTS
In the below screenshot we can see that all temporal SQL filters are showing up as applied, while the druid ones aren't, as they aren't applicable to SQL datasources:

In the below screenshot we can see that all filters are flagged as incompatible, as the datasource doesn't have the gender column, nor any temporal SQL or Druid columns:

In this screenshot, we have both legacy (top row) and v1 (bottom row) viz plugins on the same dashboard. Notice that the filters apply similar to the legacy plugins:

TEST PLAN
CI with updated old tests + new E2E test
ADDITIONAL INFORMATION