Improve resiliency

This commit is contained in:
R. Miles McCain 2020-04-16 09:42:43 -04:00
parent e8c00bf5c8
commit d28fe1a1b4
No known key found for this signature in database
GPG Key ID: 91CB47BDDF2671A5

View File

@ -51,6 +51,10 @@ def ingress_request(
ip_data = _geoip2_lookup(ip) ip_data = _geoip2_lookup(ip)
log.debug(f"Found geoip2 data") log.debug(f"Found geoip2 data")
# Validate payload
if payload.get("loadTime", 1) <= 0:
payload["loadTime"] = None
# Create or update session # Create or update session
session = ( session = (
Session.objects.filter( Session.objects.filter(
@ -59,8 +63,10 @@ def ingress_request(
ip=ip, ip=ip,
user_agent=user_agent, user_agent=user_agent,
) )
.filter(Q(identifier=identifier) | Q(identifier=""))
.first() .first()
# We used to check for identifiers, but that can cause issues when people
# re-open the page in a new tab, for example. It's better to match sessions
# solely based on IP and user agent.
) )
if session is None: if session is None:
log.debug("Cannot link to existing session; creating a new one...") log.debug("Cannot link to existing session; creating a new one...")