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 date format to the email subject #31413

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

US579
Copy link
Contributor

@US579 US579 commented Dec 12, 2024

SUMMARY

Problem
If the subject remains the same, all scheduled reports will be delivered in the same email thread, requiring the recipient to scroll back to the original thread to find the latest email.

However, if a date is included in the email subject, the emails will not be grouped in the same thread. To address this, I propose adding a feature that allows users to specify a date format in the email subject, enabling the email client to correctly thread the emails and display them in a more organized manner.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before
Screenshot 2024-12-12 at 11 57 06 am

After
Screenshot 2024-12-12 at 11 57 30 am

Screenshot 2024-12-12 at 12 01 34 pm

How to use it

Set the DATE_FORMAT_IN_EMAIL_SUBJECT=True to allow users to include a date format in the email subject, which will automatically be replaced with the corresponding actual date.

available date format https://strftime.org/

Example

In this example i defined Year-Day-Minutes

Year - %Y
Day - %D
Minutes - %M

Screenshot 2024-12-12 at 11 59 55 am

Output

Screenshot 2024-12-13 at 11 10 39 am

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: DATE_FORMAT_IN_EMAIL_SUBJECT (by default is disabled)
  • 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

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.77%. Comparing base (d5a4815) to head (224e281).

Files with missing lines Patch % Lines
superset/reports/notifications/email.py 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #31413       +/-   ##
===========================================
+ Coverage        0   83.77%   +83.77%     
===========================================
  Files           0      538      +538     
  Lines           0    39153    +39153     
===========================================
+ Hits            0    32801    +32801     
- Misses          0     6352     +6352     
Flag Coverage Δ
hive 48.76% <63.63%> (?)
mysql 76.48% <81.81%> (?)
postgres 76.56% <81.81%> (?)
presto 53.27% <63.63%> (?)
python 83.77% <90.90%> (?)
sqlite 76.02% <81.81%> (?)
unit 60.91% <81.81%> (?)

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.

@US579 US579 force-pushed the feat-allow-dates-format-string-in-superset-heading-and-description branch 2 times, most recently from 0c164a3 to eb04b3a Compare December 12, 2024 03:37
@US579 US579 force-pushed the feat-allow-dates-format-string-in-superset-heading-and-description branch from eb04b3a to 60378db Compare December 12, 2024 03:38
@@ -563,6 +563,8 @@ class D3TimeFormat(TypedDict, total=False):
# If on, you'll want to add "https://avatars.slack-edge.com" to the list of allowed
# domains in your TALISMAN_CONFIG
"SLACK_ENABLE_AVATARS": False,
# Allow users to optionally specify date formats in email subjects, which will be parsed if enabled.
"DATE_FORMAT_IN_EMAIL_SUBJECT": False,
Copy link
Member

Choose a reason for hiding this comment

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

Can you mention this new feature flag in UPDATING.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for reviewing! i have updated

@sadpandajoe
Copy link
Member

@US579 can you also add some documentation on how this is used? It won't be clear for users who don't know about this feature that they can start doing this post merge.

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.

The flag should also be documented/categorized in FEATURE_FLAGS.md

@rusackas rusackas requested a review from eschutho December 12, 2024 23:08
@US579 US579 changed the title feat: BW-3310 add dateformat to the email subject feat: add date format to the email subject Dec 12, 2024
@US579
Copy link
Contributor Author

US579 commented Dec 13, 2024

@US579 can you also add some documentation on how this is used? It won't be clear for users who don't know about this feature that they can start doing this post merge.

hey @sadpandajoe Could you point me where is the bast place to add this doc, currently i just added here

@sadpandajoe
Copy link
Member

@US579 can you also add some documentation on how this is used? It won't be clear for users who don't know about this feature that they can start doing this post merge.

hey @sadpandajoe Could you point me where is the bast place to add this doc, currently i just added here

@US579 great question. I would say you can either put it in the alerts and reports sections: https://github.com/apache/superset/blob/4ff9aac1fae2d88fd7667317c706256d3cfcb4f4/docs/docs/configuration/alerts-reports.mdx or in the faq https://github.com/apache/superset/blob/4ff9aac1fae2d88fd7667317c706256d3cfcb4f4/docs/docs/faq.mdx

@github-actions github-actions bot added the doc Namespace | Anything related to documentation label Dec 13, 2024
@@ -46,7 +46,8 @@ These features are **finished** but currently being tested. They are usable, but
- CONFIRM_DASHBOARD_DIFF
- DRILL_TO_DETAIL
- DYNAMIC_PLUGINS
- ENABLE_SUPERSET_META_DB: [(docs)](https://superset.apache.org/docs/configuration/databases/#querying-across-databases)
- DATE_FORMAT_IN_EMAIL_SUBJECT: [(docs)](https://superset.apache.org/docs/configuration/databases/#querying-across-databases)
- ENABLE_SUPERSET_META_DB: [(docs)](https://github.com/apache/superset/pull/31413)
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this docs link and the one above it are swapped.

Also, it would nice to add a docs entry rather than linking to the PR. You can run the docs locally and just add some markdown. Docs on how to do that are here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for pointing me to the right direction! i have added an entry and updated the link

@mistercrunch
Copy link
Member

Totally get the use case. Hey I'm wondering if it may make sense to support more templating in emails (subject and body) in general to tackle this use case but similar ones as well. I know jinja isn't safe for untrusted (user-provided) content, maybe we could use some pybars or something untrusted safe to allow for bringing arbitrary context in arbitrary places in the subject/body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Namespace | Anything related to documentation size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants