-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
Send email alert on low priced bounties #3174
Conversation
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
""" | ||
import json |
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.
F401 'json' imported but unused
|
||
from django.utils import timezone | ||
|
||
from bounty_requests.views import LOW_BOUNTY_THRESHOLD, bounty_request |
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.
F401 'bounty_requests.views.bounty_request' imported but unused
app/marketing/mails.py
Outdated
@@ -895,6 +895,27 @@ def new_bounty_request(model): | |||
finally: | |||
translation.activate(cur_language) | |||
|
|||
def low_bounty_request(bounty): |
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.
E302 expected 2 blank lines, found 1
a814ab4
to
0ee3452
Compare
Codecov Report
@@ Coverage Diff @@
## master #3174 +/- ##
==========================================
+ Coverage 30.11% 30.44% +0.32%
==========================================
Files 193 193
Lines 14518 14532 +14
Branches 1900 1901 +1
==========================================
+ Hits 4372 4424 +52
+ Misses 10008 9966 -42
- Partials 138 142 +4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #3174 +/- ##
==========================================
+ Coverage 30.11% 30.23% +0.11%
==========================================
Files 193 193
Lines 14577 14537 -40
Branches 1906 1901 -5
==========================================
+ Hits 4390 4395 +5
+ Misses 10049 10004 -45
Partials 138 138
Continue to review full report at Codecov.
|
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.
Hey @danlipert - Thanks for the contribution!
Would it be possible for you to update this PR to send the email when any bounty is created that doesn't reach or exceed the minimum value? It appears this is setup to only check BountyRequest
versus Bounty
.
You could probably get away with simply adding a post_save
signal for Bounty
that checks if created
and send out the email in the event the minimum isn't met.
@frankchen07 Just for clarity, it appears to me that #2808 is requesting an email notification if any bounty is created that doesn't reach or exceed the minimum. This isn't for bounty requests, right?
@mbeacom My bad! I just realized this is the wrong model! I see the actual bounties in the |
Correct.
Nope, not for bounty requests. |
0ee3452
to
c210ef7
Compare
app/dashboard/models.py
Outdated
"""Alert when a bounty with a low price is created.""" | ||
bounty = kwargs.get('instance') | ||
usdt_value = bounty.get_value_in_usdt_now | ||
if(kwargs.get('created') == True and usdt_value and usdt_value < LOW_BOUNTY_THRESHOLD): |
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.
E712 comparison to True should be 'if cond is True:' or 'if cond:'
@patch('marketing.mails.send_mail') | ||
def test_low_bounty_alert(self, mock_send_mail): | ||
"""Test that an alert email is sent when a bounty with a low value is created""" | ||
bounty = Bounty.objects.create( |
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.
F841 local variable 'bounty' is assigned to but never used
@patch('marketing.mails.send_mail') | ||
def test_no_bounty_alert_for_reasonable_bounties(self, mock_send_mail): | ||
"""Test that no alert email is sent when a bounty with a reasonable price is created.""" | ||
bounty = Bounty.objects.create( |
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.
F841 local variable 'bounty' is assigned to but never used
c210ef7
to
f2644fc
Compare
@mbeacom @frankchen07 Apologies for the confusion here - I've updated this PR with code that targets the correct model and uses the |
stale |
Description
This PR adds an alert email to the Gitcoin admins when a low-priced bounty is created. A
LOW_BOUNTY_THRESHOLD
is set, and bounties created with anamountUSDT value lower than this threshold trigger the alert.Checklist
Affected core subsystem(s)
Bounty RequestsNote:idna 2.7
was pinned in the requirements to solve a requirements conflict between the newly released idna 2.8 and therequests
library, which requiresidna<=2.7
.Refers/Fixes
Refs: #2808
Testing and Sign-off
Two functional tests were added as part of this PR, one to check that the current behavior has not changed, and one that triggers the alert email and verifies that the additional alert email is sent.
Contributor
make test
and everything passed!Reviewer
Funder