<commit_before>
class IGBMiddleware(object):
    """
    Middleware to detect the EVE IGB
    """

    def process_request(self, request):

        request.is_igb = False
        request.is_igb_trusted = False

        header_map = [
            ('HTTP_EVE_SERVERIP', 'eve_server_ip'),
            ('HTTP_EVE_CHARNAME', 'eve_charname'),
            ('HTTP_EVE_CHARID', 'eve_charid'),
            ('HTTP_EVE_CORPNAME', 'eve_corpname'),
            ('HTTP_EVE_CORPID', 'eve_corpid'),
            ('HTTP_EVE_ALLIANCENAME', 'eve_alliancename'),
            ('HTTP_EVE_ALLIANCEID', 'eve_allianceid'),
            ('HTTP_EVE_REGIONNAME', 'eve_regionid'),
            ('HTTP_EVE_CONSTELLATIONNAME', 'eve_constellationname'),
            ('HTTP_EVE_SOLARSYSTEMNAME', 'eve_systemname'),
            ('HTTP_EVE_STATIONNAME,' 'eve_stationname'),
            ('HTTP_EVE_STATIONID,' 'eve_stationid'),
            ('HTTP_EVE_CORPROLE,' 'eve_corprole'),
        ]

        if request.META.has_key('HTTP_EVE_TRUSTED'):
            request.is_igb = True
            if request.META.get('HTTP_EVE_TRUSTED') == 'Yes':
                request.is_igb_trusted = True
    
                for header, map in header_map:
                    if request.META.get(header, None):
                        setattr(request, map, request.META.get(header, None))
                            

from sso.models import SSOUserIPAddress
from datetime import datetime

class IPTrackingMiddleware(object):
    """
    Middleware to track user's IPs and insert them into the database
    """

    def process_request(self, request):

        if request.user and not request.user.is_anonymous():
            ip, created = SSOUserIPAddress.objects.get_or_create(user=request.user, ip_address=request.META['REMOTE_ADDR'].trim())
            if not created:
                ip.last_seen = datetime.utcnow()
                ip.save()<commit_msg>Fix middleware issue<commit_after>
class IGBMiddleware(object):
    """
    Middleware to detect the EVE IGB
    """

    def process_request(self, request):

        request.is_igb = False
        request.is_igb_trusted = False

        header_map = [
            ('HTTP_EVE_SERVERIP', 'eve_server_ip'),
            ('HTTP_EVE_CHARNAME', 'eve_charname'),
            ('HTTP_EVE_CHARID', 'eve_charid'),
            ('HTTP_EVE_CORPNAME', 'eve_corpname'),
            ('HTTP_EVE_CORPID', 'eve_corpid'),
            ('HTTP_EVE_ALLIANCENAME', 'eve_alliancename'),
            ('HTTP_EVE_ALLIANCEID', 'eve_allianceid'),
            ('HTTP_EVE_REGIONNAME', 'eve_regionid'),
            ('HTTP_EVE_CONSTELLATIONNAME', 'eve_constellationname'),
            ('HTTP_EVE_SOLARSYSTEMNAME', 'eve_systemname'),
            ('HTTP_EVE_STATIONNAME,' 'eve_stationname'),
            ('HTTP_EVE_STATIONID,' 'eve_stationid'),
            ('HTTP_EVE_CORPROLE,' 'eve_corprole'),
        ]

        if request.META.has_key('HTTP_EVE_TRUSTED'):
            request.is_igb = True
            if request.META.get('HTTP_EVE_TRUSTED') == 'Yes':
                request.is_igb_trusted = True
    
                for header, map in header_map:
                    if request.META.get(header, None):
                        setattr(request, map, request.META.get(header, None))
                            

from sso.models import SSOUserIPAddress
from datetime import datetime

class IPTrackingMiddleware(object):
    """
    Middleware to track user's IPs and insert them into the database
    """

    def process_request(self, request):

        if request.user and not request.user.is_anonymous():
            ip, created = SSOUserIPAddress.objects.get_or_create(user=request.user, ip_address=request.META['REMOTE_ADDR'])
            if not created:
                ip.last_seen = datetime.utcnow()
                ip.save()
{'fraction_non_alphanumeric': 0.1118421052631579, 'fraction_numerical': 0.0, 'mean_word_length': 2.305217391304348, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5732759', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1167, 'n_words': 207}