Skip to content

Commit

Permalink
fixes session handler for running tests on prod server
Browse files Browse the repository at this point in the history
  • Loading branch information
basilleaf committed Feb 7, 2017
1 parent deef71d commit b6064a2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/metrics/views.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from metrics.models import Metrics

def update_metrics(request):

if not request:
return # this is a test running

if not request.session.get('has_session'):
session_id = request.session.session_key

if not session_id:
# this user has barely touched the homepage #todo test this better
return

session_id = request.session.session_key

ip_address = get_client_ip(request)
m,v = Metrics.objects.using('metrics').get_or_create(session_id=session_id, ip_address=ip_address)
Expand Down

0 comments on commit b6064a2

Please sign in to comment.