-
Notifications
You must be signed in to change notification settings - Fork 150
/
admin_tasks.py
29 lines (22 loc) · 932 Bytes
/
admin_tasks.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
"""Collection of mapreduce jobs."""
import logging
from mapreduce import operation as op
from codereview.models import Account, Issue
def delete_unused_accounts(account):
"""Delete accounts for uses that don't participate in any reviews."""
email = account.user.email()
if Issue.query(Issue.owner_email == email).get():
return
if Issue.query(Issue.cc == email).get():
return
if Issue.query(Issue.reviewers == email).get():
return
logging.warn('Deleting %s' % email)
yield op.db.Delete(account)
def update_account_schema(account):
"""Update schema for all Accounts by saving them back to the datastore."""
# Make sure we don't alter the modified time of any accounts. Because of how
# mapreduce is designed, we just set this to False on every function
# invocation (since there's no convenient once-per-instance place to do it).
Account.modified.auto_now = False
yield op.db.Put(account)