Skip to content

Conversation

@villebro
Copy link
Member

@villebro villebro commented Oct 19, 2020

SUMMARY

Adds support for applied_filters and rejected_filters to chart data endpoint + adds support for temporal extras to both viz.py and chart data endpoint.

Short summary of changes:

Please note: needs to upgrade to new version of superset-ui/core introduced 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:
image

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:
image

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:
image

TEST PLAN

CI with updated old tests + new E2E test

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@villebro villebro changed the title Villebro/p0 extras [WIP] fix(extra-filters): add logic for identifying applied extra filters Oct 19, 2020
Comment on lines +708 to +712
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"},
)
Copy link
Member Author

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.

Comment on lines +824 to +830
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,
)
Copy link
Member Author

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-io
Copy link

codecov-io commented Oct 19, 2020

Codecov Report

Merging #11325 into feature/filter-p0 will increase coverage by 0.04%.
The diff coverage is 80.70%.

Impacted file tree graph

@@                  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     
Flag Coverage Δ
#python 60.83% <80.70%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/views/dashboard/mixin.py 95.00% <ø> (ø)
superset/utils/core.py 88.67% <73.17%> (-0.97%) ⬇️
superset/charts/schemas.py 100.00% <100.00%> (ø)
superset/common/query_context.py 87.80% <100.00%> (+0.46%) ⬆️
superset/common/query_object.py 90.90% <100.00%> (+0.16%) ⬆️
superset/models/dashboard.py 80.63% <100.00%> (ø)
superset/viz.py 57.74% <100.00%> (+0.04%) ⬆️
superset/connectors/base/models.py 89.78% <0.00%> (+0.35%) ⬆️

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 a123b24...1d63d1c. Read the comment docs.

Copy link
Member Author

@villebro villebro Oct 19, 2020

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)

@villebro villebro changed the title [WIP] fix(extra-filters): add logic for identifying applied extra filters fix(extra-filters): add logic for identifying applied extra filters Oct 19, 2020
data = fields.List(fields.Dict(), description="A list with results")
applied_filters = fields.List(
fields.Dict(), description="A list with applied 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 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}>"
Copy link
Member

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?

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

@suddjian suddjian left a comment

Choose a reason for hiding this comment

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

Thanks Ville!

@suddjian suddjian merged commit 53293e3 into apache:feature/filter-p0 Oct 19, 2020
@villebro villebro deleted the villebro/p0-extras branch October 19, 2020 17:03
suddjian added a commit that referenced this pull request Oct 28, 2020
* 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]>
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants