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

feat(native-filters): Time native filter #12992

Merged
merged 22 commits into from
Feb 13, 2021
Merged

Conversation

simcha90
Copy link
Contributor

@simcha90 simcha90 commented Feb 7, 2021

SUMMARY

This PR is continue of @agatapst PR: #12946

Here description of ☝️ PR:

The aim of this PR was to create foundations for new native filters' feature: time filters.
User can choose between one more filter type, which is Time.

That's the basics for this feature. What should be added in next PRs:

- UI improvements (if we want to show modal in modal, how to display very long time "pills" in Filter Bar etc.)
- Improve Filter Config Modal validation - right now datasource is required, but in case of time filters it should not
- Implement additional filtering: i.e. inverse
- Might also take a look on performance - it take more time to show time filters result than select filters result
- Filter indicator logic needs to be updated

In addition this PR fix some edge cases.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

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

@simcha90 simcha90 changed the title feat(native-filters) Time native filter feat(native-filters): Time native filter Feb 7, 2021
@codecov-io
Copy link

codecov-io commented Feb 7, 2021

Codecov Report

Merging #12992 (a71d35b) into master (2ce7982) will increase coverage by 14.02%.
The diff coverage is 31.11%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #12992       +/-   ##
===========================================
+ Coverage   53.06%   67.08%   +14.02%     
===========================================
  Files         489      491        +2     
  Lines       17314    28947    +11633     
  Branches     4482        0     -4482     
===========================================
+ Hits         9187    19419    +10232     
- Misses       8127     9528     +1401     
Flag Coverage Δ
cypress ?
python 67.08% <31.11%> (?)

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

Impacted Files Coverage Δ
superset/examples/birth_names.py 73.19% <ø> (ø)
...43f2fdb_add_granularity_to_charts_where_missing.py 0.00% <0.00%> (ø)
...s/260bf0649a77_migrate_x_dateunit_in_time_range.py 0.00% <0.00%> (ø)
...ons/versions/41ce8799acc3_rename_pie_label_type.py 0.00% <0.00%> (ø)
superset/connectors/sqla/views.py 62.43% <4.34%> (ø)
superset/views/datasource.py 88.70% <16.66%> (ø)
superset/charts/commands/exceptions.py 92.85% <77.77%> (ø)
superset/utils/core.py 87.99% <82.05%> (ø)
superset/db_engine_specs/elasticsearch.py 89.74% <93.75%> (ø)
superset/config.py 90.68% <100.00%> (ø)
... and 936 more

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 956f276...a71d35b. Read the comment docs.

@amitmiran137
Copy link
Member

cc: @junlincc

@junlincc junlincc added the dashboard:native-filters Related to the native filters of the Dashboard label Feb 8, 2021
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

The native filter changes look good, but I refer the review of time picker changes to @zhaoyongjie .

@zhaoyongjie
Copy link
Member

zhaoyongjie commented Feb 8, 2021

Hi @simcha90
control layout issue on the latest Firefox

image

image

@zhaoyongjie
Copy link
Member

zhaoyongjie commented Feb 8, 2021

  1. set native filter in dashboard
    image

  2. apply this filter in dashboard. select last day in time filter (no such records in cleaned sales data), expected display no data in each chart in the dashboard.
    image

  3. not apply filter
    image

� Conflicts:
�	superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.tsx
�	superset-frontend/src/dashboard/components/nativeFilters/types.ts
�	superset-frontend/src/dashboard/components/nativeFilters/utils.ts
Comment on lines 170 to 171
onChange: (timeRange: string) => void;
onTimeRangeChange?: (textValue?: string, timeRange?: string) => void;
Copy link
Member

Choose a reason for hiding this comment

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

onChange and onTimeRangeChange seem to have the same function, can we merge these props?

response?.json?.result?.until || '',
);
const { since = '', until = '' } = response?.json?.result || {};
const timeRangeString = buildTimeRangeString(since, until);
Copy link
Member

Choose a reason for hiding this comment

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

NEED to double check here.
timeRangeString is Absolute time range.
eg:
if today is 2021-2-8, then last day, generate "2021-02-07 : 2021-02-08".
when the 2021-3-8, then last day generate "2021-03-07 : 2021-03-08"

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

need double check

@junlincc
Copy link
Member

junlincc commented Feb 8, 2021

@simcha90 thanks for taking over the project! really appreciate you work

tested and the basic functionality is working, can not fully test until the filter is connected to the indicator. @zhaoyongjie we should either skip the time column select or pre-select dttm column for your user, or simply narrow it down to show date column only in select dropdown.
Also there's noticeable layout issue of regular filter on the left bar.
Priority fo next steps -

  1. Layout - make sure user can change filter value of regular filter (reason: we need to keep this feature in minimal demo-able state)

Screen Shot 2021-02-08 at 7 22 23 AM

  1. connect to filter indicator and magnifier

  2. Improve Filter Config Modal validation, populate only date/datetime/time columns in select

  3. Performance

  4. Inverse

Screen.Recording.2021-02-08.at.7.17.12.AM.mov

@junlincc
Copy link
Member

junlincc commented Feb 8, 2021

need double check

@villebro @simcha90 @zhaoyongjie what is the scope of this PR?
i listed my priority in last comment, can we make incremental changes based on the order?

@junlincc
Copy link
Member

junlincc commented Feb 9, 2021

we also lost the indicator hook that we Agata previously implemented for the regular filter type. @simcha90 could you please double check? this is not ready to merge yet. @villebro

@junlincc junlincc added the hold:testing! On hold for testing label Feb 9, 2021
@simcha90
Copy link
Contributor Author

simcha90 commented Feb 10, 2021

@junlincc I think scope of this PR - is ability to set TimeFilter as native filter and also set default value for it. All other additional features should be implemented in other PRs, and can be done in different times after this PR will be merged, because this PR is base PR for all other features. cc @villebro

@zhaoyongjie
Copy link
Member

zhaoyongjie commented Feb 10, 2021

Hi, @simcha90, @villebro, @junlincc

The implementation of this PR still needs to be considered. Now the filter passed by the native filter to each chart is the specific time. For example, if you choose, Last week, it will transform to 2021-01-01 : 2021-01-02. This applies to The chart filter will not change. Imagine a scenario, this will cause a problem. After you select Last week, set the Dashboard to refresh by every minute. Then the chart will not update the filter.

const metadata = new ChartMetadata({
name: t('Time range filter plugin'),
description: 'Custom time filter plugin',
behaviors: [Behavior.NATIVE_FILTER],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it can be also CROSS_FILTER

@simcha90
Copy link
Contributor Author

simcha90 commented Feb 11, 2021

@villebro

  1. I think it have some inconsistencies, like if I choose Custom default value it shows like this
    image

  2. If I choose previous week it shows dates in filter bar instead of previous week, but after reload it shows previous week

image

<Styles width={width}>
<DateFilterControl
value={value}
name=""
Copy link
Member

@zhaoyongjie zhaoyongjie Feb 12, 2021

Choose a reason for hiding this comment

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

one nit:
could we set a default name for DateFilterControl ?

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

LGTM, thanks ville.

@junlincc
Copy link
Member

junlincc commented Feb 12, 2021

LGTM! ✅
will be connecting to filter indicators and adding unit test in follow up PRs.

@junlincc junlincc self-requested a review February 12, 2021 15:29
@villebro villebro merged commit d6fc720 into apache:master Feb 13, 2021
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request Feb 14, 2021
* Add Time Filter component

* Improve Time Filter component

* Fix import errors

* Display Time Filter

* Remove console logs

* Change Control Panel

* Remove unnecessary files

* Use time range override

* test: fix tests

* feat: re run pipeline

* fix: fix some case for Time filter

* fix: merge with master

* use original time range

* fix height

* add cross filter behavior

* apply filters on initialization

* add applied filter to overrides

* add unit tests for merge_extra_form_data

Co-authored-by: Agata Stawarz-Pastewska <agata.stawarz-pastewska@polidea.com>
Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request Feb 14, 2021
* master: (30 commits)
  refactor(native-filters): decouple params from filter config modal (first phase) (apache#13021)
  fix(native-filters): set currentValue null when empty (apache#13000)
  Custom superset_config.py + secret envs (apache#13096)
  Update http error code from 400 to 403 (apache#13061)
  feat(native-filters): add storybook entry for select filter (apache#13005)
  feat(native-filters): Time native filter (apache#12992)
  Force pod restart on config changes (apache#13056)
  feat(cross-filters): add cross filters (apache#12662)
  fix(explore): Enable selecting an option not included in suggestions (apache#13029)
  Improves RTL configuration (apache#13079)
  Added a note about the ! prefix for breaking changes to CONTRIBUTING.md (apache#13083)
  chore: lock down npm to v6 (apache#13069)
  fix: API tests, make them possible to run independently again (apache#13076)
  fix: add config to disable dataset ownership on the old api (apache#13051)
  add required * indicator to message content/notif method (apache#12931)
  fix: Retroactively add granularity param to charts (apache#12960)
  fix(ci): multiline regex in change detection (apache#13075)
  feat(style): hide dashboard header by url parameter (apache#12918)
  fix(explore): pie chart label bugs (apache#13052)
  fix: Disabled state button transition time (apache#13008)
  ...
@junlincc junlincc removed the hold:testing! On hold for testing label Mar 12, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels dashboard:native-filters Related to the native filters of the Dashboard 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants