Commit 6398f28a authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

More log messages in cleanup method

parent 746bf927
......@@ -12,8 +12,10 @@ htmlcov/
dist/
build/
*.egg-info/
.tox/
# Ignore configurations for specific environments
eidawsauth/config.yaml
eidawsauth/configurations/*
!eidawsauth/configurations/default.py
!eidawsauth/configurations/__init__.py
......@@ -138,6 +138,7 @@ def cleanup():
"""
Clean old temporary logins and passwords in both databases.
"""
logger.info("Cleaning up expired temporary accounts")
try:
conn = psycopg2.connect(dbname= application.config['AUTHDBNAME'],
port = application.config['AUTHDBPORT'],
......@@ -154,6 +155,7 @@ def cleanup():
raise e
cur.execute("select user_index,login from users where expires_at < now();")
expired_accounts = cur.rowcount()
old_users_entries = cur.fetchall()[:1000]
old_users = ','.join( str(u[0]) for u in old_users_entries )
logging.debug("%d users to delete"%(len(old_users_entries)))
......@@ -188,7 +190,8 @@ def cleanup():
""", (old_users,))
conn.commit()
conn.close()
return Response("Deleted %d temporary accounts."%(len(old_users_entries)), status=200)
logger.info("Deleted %d/%d expired accounts")%(len(old_users_entries), expired_accounts)
return Response("Deleted %d expired accounts."%(len(old_users_entries)), status=200)
@application.route("/", methods=['POST'])
def auth():
......
__version__='0.3.2'
__version__='0.3.3'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment