superset icon indicating copy to clipboard operation
superset copied to clipboard

feat: add Current time-range options for time filter

Open pranav1699 opened this issue 1 year ago • 8 comments

SUMMARY

This pull request introduces a new "Current" option to the time filter component. The "Current" option allows users to select and view data for the current week, current month, and current year.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: image

After : image

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • [x] Has associated issue: https://github.com/apache/superset/issues/28489
  • [ ] Required feature flags:
  • [x] Changes UI
  • [ ] Includes DB Migration (follow approval process in SIP-59)
    • [ ] Migration is atomic, supports rollback & is backwards-compatible
    • [ ] Confirm DB migration upgrade and downgrade tested
    • [ ] Runtime estimates and downtime expectations provided
  • [x] Introduces new feature or API
  • [ ] Removes existing feature or API

pranav1699 avatar May 22 '24 12:05 pranav1699

Hi @rusackas @sfirke , could you please review the PR. Thanks!

pranav1699 avatar May 22 '24 12:05 pranav1699

also related to #28626 (I hadn't found the other feature request when I created mine).

jakejh avatar May 22 '24 16:05 jakejh

Looking at the AFTER screenshot, it looks like current calendar week should be from 2024-05-20 to 2024-05-26 instead of 2024-05-20 to today as we may have future data and when I select current calendar week I expect to see those.

michael-s-molina avatar May 22 '24 17:05 michael-s-molina

Looking at the AFTER screenshot, it looks like current calendar week should be from 2024-05-20 to 2024-05-26 instead of 2024-05-20 to today as we may have future data and when I select current calendar week I expect to see those.

I agree with @michael-s-molina, I have edited my comment above to align with this suggestion.

sfirke avatar May 22 '24 17:05 sfirke

Hey @sfirke @michael-s-molina , I have made all the changes you mentioned. Could you please review it now? Thanks!

image

pranav1699 avatar May 22 '24 17:05 pranav1699

Codecov Report

Attention: Patch coverage is 55.88235% with 15 lines in your changes missing coverage. Please review.

Project coverage is 70.28%. Comparing base (76d897e) to head (d721931). Report is 1094 commits behind head on master.

Files with missing lines Patch % Lines
...eFilterControl/components/CurrentCalendarFrame.tsx 0.00% 12 Missing :warning:
...ontrols/DateFilterControl/utils/dateFilterUtils.ts 0.00% 1 Missing and 1 partial :warning:
...nts/controls/DateFilterControl/DateFilterLabel.tsx 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #28637      +/-   ##
==========================================
+ Coverage   60.48%   70.28%   +9.79%     
==========================================
  Files        1931     1946      +15     
  Lines       76236    77531    +1295     
  Branches     8568     8736     +168     
==========================================
+ Hits        46114    54489    +8375     
+ Misses      28017    20911    -7106     
- Partials     2105     2131      +26     
Flag Coverage Δ
hive 48.94% <0.00%> (-0.23%) :arrow_down:
mysql 77.18% <50.00%> (?)
postgres 77.31% <50.00%> (?)
presto 53.55% <50.00%> (-0.25%) :arrow_down:
python 83.61% <100.00%> (+20.12%) :arrow_up:
sqlite 76.76% <50.00%> (?)
unit 59.00% <100.00%> (+1.37%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 22 '24 18:05 codecov[bot]

All checks passed. Please review and merge if possible. Thanks!

pranav1699 avatar May 23 '24 15:05 pranav1699

@betodealmeida or @villebro is one of you able to review this? I approved, the functionality looks good to me and it's a nice addition that's passing all tests. But I'd like someone who can evaluate the code quality + style and determine if the Codecov warnings are relevant.

sfirke avatar May 23 '24 16:05 sfirke

/testenv up

rusackas avatar May 30 '24 05:05 rusackas

@rusackas Ephemeral environment spinning up at http://18.236.146.162:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

github-actions[bot] avatar May 30 '24 05:05 github-actions[bot]

Agreed this is worth shipping as-is, and I'm tempted to merge it, BUT I need to ask the obvious question:

@pranav1699 would you be able/willing to add any tests? I know these time ranges are not particularly well tested, but maybe this is a good excuse to add a few tests that make sure it's calculating the time ranges as expected. This would help affirm expectations around time ranges as discussed/fixed in the thread above.

rusackas avatar May 31 '24 23:05 rusackas

@rusackas I've added Python unit tests for the current time range. Thanks for suggesting it.

pranav1699 avatar Jun 01 '24 05:06 pranav1699

Running CI 🤞

rusackas avatar Jun 03 '24 18:06 rusackas

Ephemeral environment shutdown and build artifacts deleted.

github-actions[bot] avatar Jun 06 '24 20:06 github-actions[bot]

Thanks again for this @pranav1699! I hope you will consider future contributions to Superset, I appreciated how thorough your PR code was and your responsiveness 🙏

sfirke avatar Jun 07 '24 14:06 sfirke

You're welcome! I'm glad you found my contributions helpful. Thank you for reviewing the changes and all. I'll definitely keep Superset on my radar for future contributions.

pranav1699 avatar Jun 07 '24 18:06 pranav1699