-
Notifications
You must be signed in to change notification settings - Fork 308
Conversation
I'm planning to write a script to queue this locally, with a production Mandrill key in |
I tried a bit to find an old gratipocalypse branch that I thought might have the script on it that I used for the Gratipocalypse email, but alackaday.
But not in text/plain. :P
Takes a limit and returns the number sent. This commit may be worth cherry-picking and testing.
So we can do `from gratipay.main import db` in scripts.
Subject: Gratipay, Year Three |
Okay! Ready? |
I'm downloading a backup. I'll use that to populate the |
Backup loaded. => select count(*) from participants where email_address is not null
and is_suspicious is not true and is_closed is not true and claimed_time is not null;
┌───────┐
│ count │
├───────┤
│ 2812 │
└───────┘
(1 row) |
Matches production. As I recall we mailed Gratipocalypse to ~2600 folks. We've picked up 200 email addresses since then, I suppose? |
Indeed! :) => select count(*) from emails where verified and verification_end > 'May 7, 2015';
┌───────┐
│ count │
├───────┤
│ 239 │
└───────┘
(1 row) |
Alright, list of participants ready to go in local db ... |
Okay, my [gratipay] $ run_dammit defaults.env local.env -c ./env/bin/python bin/send-year-three.py Here's |
I expect the next run to output 2812 and then fail on the first assert. |
For 2,812 emails at 1 per second, it's going to take 47 minutes to send all of these out. It'd be nice if that went faster. What are our rate limits at Mandrill? |
Our hourly limit is 6,561. |
What if I use |
Hmm ... would have to unroll/monkey around with |
Why was it added in the first place? |
Yeah, I'm not finding an explanation for why we implemented throttling the way we did. I'm going to whack the sleep for this mail run. |
Still might take a second per API call. We'll see. :) |
The email queue doesn't look thread-safe to me, anyway. |
So far so good ... [gratipay] $ run_dammit defaults.env local.env -c ./env/bin/python bin/send-year-three.py
2812
[snip]
Traceback (most recent call last):
File "bin/send-year-three.py", line 37, in <module>
assert len(participants) == 1
AssertionError
[gratipay] $ |
diff --git a/gratipay/models/participant.py b/gratipay/models/participant.py
index a8ae2f9..b20c04d 100644
--- a/gratipay/models/participant.py
+++ b/gratipay/models/participant.py
@@ -688,7 +688,7 @@ class Participant(Model, MixinTeam):
p = cls.from_id(msg.participant)
r = p.send_email(msg.spt_name, **pickle.loads(msg.context))
cls.db.run("DELETE FROM email_queue WHERE id = %s", (msg.id,))
- if r == 1:
+ if 0 and r == 1:
sleep(1)
nsent += r
return nsent |
diff --git a/bin/send-year-three.py b/bin/send-year-three.py
index 698bb2b..1bd2363 100644
--- a/bin/send-year-three.py
+++ b/bin/send-year-three.py
@@ -34,8 +34,8 @@ print([(p.username, p.email_address) for p in random.sample(participants, 5 if N
# ----------------------------------------- SAFETY BELT ----------------------------------------- #
# ----------------------------------------- SAFETY BELT ----------------------------------------- #
# ----------------------------------------- SAFETY BELT ----------------------------------------- #
-assert len(participants) == 1
-assert participants[0].email_address == '[email protected]'
+#assert len(participants) == 1
+#assert participants[0].email_address == '[email protected]'
# ----------------------------------------- SAFETY BELT ----------------------------------------- #
# ----------------------------------------- SAFETY BELT ----------------------------------------- #
# ----------------------------------------- SAFETY BELT ----------------------------------------- #
diff --git a/gratipay/models/participant.py b/gratipay/models/participant.py
index a8ae2f9..b20c04d 100644
--- a/gratipay/models/participant.py
+++ b/gratipay/models/participant.py
@@ -688,7 +688,7 @@ class Participant(Model, MixinTeam):
p = cls.from_id(msg.participant)
r = p.send_email(msg.spt_name, **pickle.loads(msg.context))
cls.db.run("DELETE FROM email_queue WHERE id = %s", (msg.id,))
- if r == 1:
+ if 0 and r == 1:
sleep(1)
nsent += r
return nsent |
Script started! [gratipay] $ run_dammit defaults.env local.env -c ./env/bin/python bin/send-year-three.py > send-year-three.log |
Queueing ... |
Wish I turned off stdio buffering. :-/ |
Ack. I killed the script because I thought for a second that I had loaded up the production email queue, in which case the |
=# select count(*) from email_queue;
┌───────┐
│ count │
├───────┤
│ 2628 │
└───────┘
(1 row) |
Rerunning as ... #!/usr/bin/env python
"""This is a one-off script to send emails for #3510.
"""
from __future__ import print_function
import sys
class DevNull:
def write(*a): pass
def flush(*a): pass
sys.stdout = DevNull()
from gratipay.main import Participant
sys.stdout = sys.__stdout__
print("Flushing email queue ...")
nsent = Participant.dequeue_emails()
print("Sent {} email{}.".format(nsent, '' if nsent == 1 else 's')) |
$ watch -n1 "psql gratipay-bak -c 'select count(*) from email_queue;'" |
Definitely going faster than one per second. :) |
Okay! Emails 2315, Supper 1 :] bbiab ... |
|
💃 |
Production Mandrill key removed from my |
If I had it to do over again I would've emphasized the changes more: we're not "back to processing" for most users. :-( |
Here is the only record we have of the Gratipocalypse mailing: #3385 (comment). |
I'd have to agree that there seem to be a fair number of people who didn't catch the team approval requirement. Some have emailed support since then, some (as shown in these recent tweets) don't realize they aren't receiving anymore. |
:-/ Let's try to do a better job of communicating with #3539. P.S. Thanks for rep'ing on Twitter. |
Picking up from #3508.