-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Add support for a default alert template #5996
Conversation
96e9306
to
b6e99e0
Compare
@eradman thanks for your contribution! Would you mind rebasing on |
This LGTM! Would you mind also opening a PR for docs for cc @justinclift |
Certainly! Proposed an update to the docs in getredash/website#673 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have test coverage for them.
I will write some test cases update this PR |
Awesome. 😄 |
I added tests to verify that mustache variables are rendered correctly in the context of an alert. Early next week I'll review this change again and see if there are other tests that should be included. |
Thanks @eradman, sounds like a plan. 😄 |
21b08f7
to
3132e6e
Compare
There does not seem to be an existing set of test cases for I would say that the mustache template rendering is covered reasonably. |
We're getting closer: I was able to refactor this so that the query contents are rendered in the template. Also access to MailDev was broken: we need to map port 1025 and make sure Redash uses that port to send mail. I can push this as a separate commit. |
As a thought for this, please make sure it's not something too hard coded. Not everyone needs to use the docker container for sending emails. eg in the production instances I manage, we just have things going directly via SMTP2GO, no docker container needed |
In this case, # This configuration file is for the **development** setup.
# For a production example please refer to getredash/setup repository on GitHub. |
Cool. 😄 |
Fixed flake8 and rebased |
Fixed black, isort warnings |
@eradman |
- Escape all variables by default since Mustache only has a syntax for raw values - Generate a generic HTML result table to allow an alert template to display any query - Optionally allow alert template to be defined to be set using REDASH_ALERTS_DEFAULT_MAIL_BODY_TEMPLATE - Formatting updated by black
Oh because I was using black-21 (from Ubuntu 22). Upgraded to black-23 ran format again |
Codecov Report
@@ Coverage Diff @@
## master #5996 +/- ##
==========================================
+ Coverage 59.91% 59.97% +0.06%
==========================================
Files 153 153
Lines 12462 12470 +8
Branches 1684 1686 +2
==========================================
+ Hits 7466 7479 +13
+ Misses 4790 4783 -7
- Partials 206 208 +2
|
@eradman It looks like this is pretty much ready to merge yeah? Also, is there a clear way forward for this?
Personally speaking, I'm not bothered either way if the port mapping is a separate |
This is ready to to go. I manually confirmed that email alerts are formatted properly and I'd say the implementation is in good shape. I created PR #6186 with the changes to the docker port mapping. I believe if we merge that first this change will apply cleanly. |
Cool. Just merged the other one, so I'll merge this after the CI tests all pass again. 😄 |
Cool, all done. This seems like it'll be a useful addition for people @eradman. 😄 |
Indeed; I'm sure others will find this change useful. Thanks for mentoring this along @justinclift @guidopetri @junnplus |
- Escape all variables by default since Mustache only has a syntax for raw values - Generate a generic HTML result table to allow an alert template to display any query - Optionally allow alert template to be defined to be set using REDASH_ALERTS_DEFAULT_MAIL_BODY_TEMPLATE - Formatting updated by black
Description
Add support for a default alert template
REDASH_ALERTS_DEFAULT_MAIL_BODY_TEMPLATE
Mobile & Desktop Screenshots/Recordings (if there are UI changes)