-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.py
60 lines (40 loc) · 1.45 KB
/
queue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import logging
import random
import time
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from emailer import Emailer
from helpers import *
from models import User
#### Task Queue Functions ####
##############################
class DailyEmailSender( webapp.RequestHandler ):
def post( self ):
uuid = self.request.get( 'uuid' )
u = User.get_by_uuid( uuid )
random.seed( uuid )
time.sleep( random.randint(0, 29) )
Emailer.dailyEmail( u )
class MonthlySummarySender( webapp.RequestHandler ):
def post( self ):
uuid = self.request.get( 'uuid' )
u = User.get_by_uuid( uuid )
random.seed( uuid )
time.sleep( random.randint(0, 29) )
Emailer.monthlySummary( u )
u.reset()
class ResetPlayedFlag( webapp.RequestHandler ):
def post( self ):
uuid = self.request.get( 'uuid' )
u = User.get_by_uuid( uuid )
u.played_today = False
u.save()
application = webapp.WSGIApplication([
('/queue/dailyEmail', DailyEmailSender),
('/queue/monthlySummary', MonthlySummarySender),
('/queue/playedFlagReset', ResetPlayedFlag)
], debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()