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: add Current time-range options for time filter #28637

Merged
merged 12 commits into from
Jun 6, 2024

Conversation

pranav1699
Copy link
Contributor

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

  • Has associated issue: [SIP-133] Update "Time Range" filter in dashboard #28489
  • Required feature flags:
  • 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
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot bot added change:frontend Requires changing the frontend explore:time Related to the time filters in Explore labels May 22, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@pranav1699
Copy link
Contributor Author

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

Copy link
Member

@sfirke sfirke left a comment

Choose a reason for hiding this comment

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

Thanks for adding this! I think it generally should be an uncontroversial addition and provide something that lots of people have asked for. My initial thoughts:

  • Looks like it is failing CI, please investigate the failed checks and address. Ping me if you need me to re-approve the checks to run. I see at least prettier needs to be run to format the code.
  • To clarify, I don't think this addresses the SIP-133 discussion you linked which is fine. It does address a common feature request: Feature request: Time filter range type of "Current" #21804. Please read through that discussion for context. Could you also add Current Day and Current Quarter per my request there? This would give it parity with the other time types.
  • Suggestion: the "current" time ranges ends at DATETRUNC(DATETIME('today'), DAY), should they instead continue through a full day/week/month/quarter/year? E.g., for current week would end DATETRUNC(DATEADD(DATETIME('today'), 1, WEEK), WEEK), while current day would end at DATETRUNC(DATEADD(DATETIME('today'), 1, DAY), DAY) etc.

@jakejh
Copy link

jakejh commented May 22, 2024

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

@michael-s-molina
Copy link
Member

michael-s-molina commented May 22, 2024

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.

@sfirke
Copy link
Member

sfirke commented May 22, 2024

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.

@pranav1699
Copy link
Contributor Author

pranav1699 commented May 22, 2024

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

image

@pranav1699 pranav1699 requested a review from sfirke May 22, 2024 18:05
Copy link

codecov bot commented May 22, 2024

Codecov Report

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

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

Files Patch % Lines
...eFilterControl/components/CurrentCalendarFrame.tsx 0.00% 12 Missing ⚠️
...ontrols/DateFilterControl/utils/dateFilterUtils.ts 0.00% 1 Missing and 1 partial ⚠️
...nts/controls/DateFilterControl/DateFilterLabel.tsx 0.00% 0 Missing and 1 partial ⚠️
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%) ⬇️
mysql 77.18% <50.00%> (?)
postgres 77.31% <50.00%> (?)
presto 53.55% <50.00%> (-0.25%) ⬇️
python 83.61% <100.00%> (+20.12%) ⬆️
sqlite 76.76% <50.00%> (?)
unit 59.00% <100.00%> (+1.37%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pranav1699
Copy link
Contributor Author

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

Copy link
Member

@sfirke sfirke left a comment

Choose a reason for hiding this comment

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

Looking good to me! I had one comment about a line whose formatting didn't match the surrounding. Otherwise I'm good with this, though let's see if we can get a review from someone who knows this code.

I see Codecov is warning about lines not being covered by tests, should that be addressed?

@sfirke
Copy link
Member

sfirke commented May 23, 2024

@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.

@pranav1699 pranav1699 requested a review from sfirke May 23, 2024 17:06
@rusackas
Copy link
Member

/testenv up

Copy link
Contributor

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

Copy link
Member

@sfirke sfirke left a comment

Choose a reason for hiding this comment

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

I played around with this on the ephemeral and it works as it should. I will vouch for the logic being correct and the feature needed; can another contributor approve + merge after taking a look at the code quality/style/coverage? This would be a nice win to ship in 4.1.0 and should not linger, given that it works great and is in high demand.

@rusackas
Copy link
Member

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.

@pranav1699
Copy link
Contributor Author

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

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Thanks, this looks great!

@rusackas
Copy link
Member

rusackas commented Jun 3, 2024

Running CI 🤞

@rusackas rusackas merged commit 066f6b1 into apache:master Jun 6, 2024
35 checks passed
Copy link
Contributor

github-actions bot commented Jun 6, 2024

Ephemeral environment shutdown and build artifacts deleted.

@pranav1699 pranav1699 deleted the filter-features branch June 7, 2024 02:07
@sfirke
Copy link
Member

sfirke commented Jun 7, 2024

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 🙏

@pranav1699
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:frontend Requires changing the frontend explore:time Related to the time filters in Explore size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants