示例#1
0
    def active(self, timeout=None):
        """
        Retrieves only visitors who have been active within the timeout
        period.
        """
        if not timeout:
            timeout = utils.get_timeout()

        now = timezone.now()
        cutoff = now - timedelta(minutes=timeout)

        return self.get_queryset().filter(last_update__gte=cutoff)
示例#2
0
    def active(self, timeout=None):
        """
        Retrieves only visitors who have been active within the timeout
        period.
        """
        if not timeout:
            timeout = utils.get_timeout()

        now = datetime.now()
        cutoff = now - timedelta(minutes=timeout)

        return self.get_query_set().filter(last_update__gte=cutoff)
    def process_request(self, request):

        last_clean_time = cache.get('activeusers_last_cleanup')
        now = datetime.now()
        x_minutes_ago = now - timedelta(minutes=int(utils.get_timeout()) / 2)

        if not last_clean_time or last_clean_time <= x_minutes_ago:
            cache.set('activeusers_last_cleanup', now)

            timeout = utils.get_cleanup_timeout()
            if str(timeout).isdigit():
                timeout = datetime.now() - timedelta(hours=int(timeout))
                Visitor.objects.filter(last_update__lte=timeout).delete()
    def process_request(self, request):

        last_clean_time = cache.get('activeusers_last_cleanup')
        now = timezone.now()
        x_minutes_ago = now - timedelta(minutes=int(utils.get_timeout()) / 2)

        if not last_clean_time or last_clean_time <= x_minutes_ago:
            cache.set('activeusers_last_cleanup', now)

            timeout = utils.get_cleanup_timeout()
            if str(timeout).isdigit():
                timeout = timezone.now() - timedelta(hours=int(timeout))
                Visitor.objects.filter(last_update__lte=timeout).delete()