def get_health(request):
    def num_users(minutes):
        users = 0
        for session in Session.objects.all():
            try:
                decoded = session.get_decoded()
            except:
                #There's a problem with this session, remove it
                session.delete()
                continue
            
            if 'activity_time' in decoded:
                activity_delta = decoded['activity_time'] - timedelta(0,0,0,0,settings.SESSION_TIMEOUT)
                if (datetime.now() - timedelta(0,0,0,0,minutes)) > activity_delta:
                    users += 1
        return users

    try:
        result = _('Health retrieved at %(time)s\n') % {'time': datetime.now()}
        result += _('%(plan_count)d plans in database\n') % \
                {'plan_count': Plan.objects.all().count()}
        result += _('%(session_count)d sessions in use out of %(session_limit)s\n') % \
                {'session_count': Session.objects.all().count(),
                'session_limit': settings.CONCURRENT_SESSIONS}
        result += _('%(num_users)d active users over the last 10 minutes\n') % \
                {'num_users':  num_users(10)}
        space = os.statvfs('/projects/PublicMapping')
        result += _('%(mb_free)s MB of disk space free\n') % \
                {'mb_free': ((space.f_bsize * space.f_bavail) / (1024*1024))}
        result += _('Memory Usage:\n%(mem_free)s\n') % \
                {'mem_free':  commands.getoutput('free -m')}
        return HttpResponse(result, mimetype='text/plain')
    except:
        return HttpResponse(_("ERROR! Couldn't get health:\n%s") % traceback.format_exc())
dataset/ETHPy150Open PublicMapping/DistrictBuilder/django/publicmapping/redistricting/views.py/get_health/swapped operands of `>`