Skip to content

Commit

Permalink
Add a spam measure to the stats email
Browse files Browse the repository at this point in the history
  • Loading branch information
thenoviceoof committed Mar 4, 2012
1 parent 937f863 commit 8bdcf31
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
15 changes: 13 additions & 2 deletions admin.py
Expand Up @@ -144,6 +144,16 @@ def get(self):
joint_query = EmailToClub.all()
joint_query.filter("created_at >", yesterday)
new_joints = joint_query.fetch(100)
# and get the newly disabled links
joint_query = EmailToClub.all()
joint_query.filter("updated_at >", yesterday)
joint_query.filter("enable =", False)
dead_joints = joint_query.fetch(100)

if (not(new_clubs) and not(new_emails) and not(new_flyers)
and not(new_joints)):
self.response.out.write("Nothing to email")
return

# email sending pre-computation
fromaddr = "noreply@%s.appspotmail.com" % get_application_id()
Expand All @@ -157,14 +167,15 @@ def get(self):
{"clubs": new_clubs,
"emails": new_emails,
"flyers": new_flyers,
"joints": new_joints})
"joints": new_joints,
"dead_joints": dead_joints})
try:
msg.send()
except apiproxy_errors.OverQuotaError, (message,):
# Log the error.
logging.error("Could not send email")
logging.error(message)
self.response.out.write("Sent emails")
self.response.out.write("Sent emails")

application = webapp.WSGIApplication(
[('/tasks/email', EmailHandler),
Expand Down
2 changes: 2 additions & 0 deletions flyer.py
Expand Up @@ -645,6 +645,7 @@ def post(self, job_id):
join = join_query.get()
# do the delete
join.enable = False
join.updated_at = datetime.now()
join.put()
# mark all the jobs inactive
flyer_query = Flyer.all()
Expand Down Expand Up @@ -696,6 +697,7 @@ def post(self, job_id):
# do the delete
for join in joins:
join.enable = False
join.updated_at = datetime.now()
join.put()
# mark all the jobs inactive
job_query = Job.all()
Expand Down
1 change: 1 addition & 0 deletions models.py
Expand Up @@ -86,3 +86,4 @@ class EmailToClub(db.Model):
admin = db.BooleanProperty(default=False)
# timestamps
created_at = db.DateTimeProperty(auto_now_add=True)
updated_at = db.DateTimeProperty(auto_now_add=True)
13 changes: 13 additions & 0 deletions templates/email_stats.html
Expand Up @@ -6,16 +6,29 @@ <h1>New Clubs</h1>
</ul>

<h1>New Emails</h1>
<ul>
{% for email in emails %}
<li>{{ email.email }}</li>
{% endfor %}
</ul>

<h1>New Flyers</h1>
<ul>
{% for flyer in flyers %}
<li>{{ flyer.name }} by {{ flyer.club.name }}</li>
{% endfor %}
</ul>

<h1>New Email/Club Joins</h1>
<ul>
{% for joint in joints %}
<li>Join {{ joint.email.email }} and {{ joint.club.name }}</li>
{% endfor %}
</ul>

<h1>Disabled Email/Club Joins</h1>
<ul>
{% for joint in dead_joints %}
<li>Sever {{ joint.email.email }} and {{ joint.club.name }}</li>
{% endfor %}
</ul>

0 comments on commit 8bdcf31

Please sign in to comment.