Add IP address to current activity

This commit is contained in:
Jonathan Wong 2015-11-10 19:28:14 -08:00
parent 0c33e7492a
commit fd9cf7017b
4 changed files with 34 additions and 1 deletions

View file

@ -998,4 +998,21 @@ class DataFactory(object):
else:
return 'No updated rating key needed in database. No changes were made.'
# for debugging
#return mapping
#return mapping
def get_session_ip(self, session_key=''):
monitor_db = database.MonitorDatabase()
if session_key:
query = 'SELECT CASE WHEN ip_address IS NULL THEN "N/A" ELSE ip_address END ' \
'FROM sessions WHERE session_key = %d' % int(session_key)
result = monitor_db.select(query)
else:
return None
ip_address = 'N/A'
for item in result:
ip_address = item[0]
return ip_address