-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathutil.py
38 lines (32 loc) · 1.05 KB
/
util.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
import logging, email
from datetime import tzinfo, datetime, timedelta
# This function recreates the SigninRecord table from scratch
# (May never need to be used again)
def init_records():
import main
logging.info("Wiping old SigninRecord table.")
for s in main.SigninRecord.all():
s.delete()
logging.info("Scanning signin table.")
count = {}
first = {}
last = {}
for signin in main.Signin.all().order("created"):
if signin.email not in first:
first[signin.email] = signin.created
if signin.email not in count:
count[signin.email] = 1
else:
count[signin.email] += 1
last[signin.email] = signin.created
logging.info("Populating SigninRecord table.")
for email in count:
main.SigninRecord(email=email, first_signin = first[email], last_signin=last[email], signins = count[email]).put()
logging.info("Done.")
class Pacific(tzinfo):
def utcoffset(self,dt):
return timedelta(hours=-8,minutes=0)
def tzname(self,dt):
return "GMT -8"
def dst(self,dt):
return timedelta(0)