@login_required
def my_checks(request, code):
    _refresh_last_active_date(request.profile)
    (project, rw) = _get_project_for_user(request, code)
    if (request.GET.get('sort') in VALID_SORT_VALUES):
        request.profile.sort = request.GET['sort']
        request.profile.save()
    if (request.session.get('last_project_id') != project.id):
        request.session['last_project_id'] = project.id
    q = Check.objects.filter(project=project)
    checks = list(q.prefetch_related('channel_set'))
    sortchecks(checks, request.profile.sort)
    (tags_statuses, num_down) = _tags_statuses(checks)
    pairs = list(tags_statuses.items())
    pairs.sort(key=(lambda pair: pair[0].lower()))
    channels = Channel.objects.filter(project=project)
    channels = list(channels.order_by('created'))
    hidden_checks = set()
    selected_tags = set(request.GET.getlist('tag', []))
    if selected_tags:
        for check in checks:
            if (not selected_tags.issubset(check.tags_list())):
                hidden_checks.add(check)
    search = request.GET.get('search', '')
    if search:
        for check in checks:
            search_key = ('%s\n%s' % (check.name.lower(), check.code))
            if (search not in search_key):
                hidden_checks.add(check)
    show_last_duration = False
    for check in checks:
        if check.clamped_last_duration():
            show_last_duration = True
            break
    ctx = {'page': 'checks', 'rw': rw, 'checks': checks, 'channels': channels, 'num_down': num_down, 'tags': pairs, 'ping_endpoint': settings.PING_ENDPOINT, 'timezones': pytz.all_timezones, 'project': project, 'num_available': project.num_checks_available(), 'sort': request.profile.sort, 'selected_tags': selected_tags, 'search': search, 'hidden_checks': hidden_checks, 'show_last_duration': show_last_duration}
    return render(request, 'front/my_checks.html', ctx)
@login_required
def my_checks(request, code):
    _refresh_last_active_date(request.profile)
    (project, rw) = _get_project_for_user(request, code)
    if (request.GET.get('sort') in VALID_SORT_VALUES):
        request.profile.sort = request.GET['sort']
        request.profile.save()
    if (request.session.get('last_project_id') != project.id):
        request.session['last_project_id'] = project.id
    q = Check.objects.filter(project=project)
    checks = list(q.prefetch_related('channel_set'))
    sortchecks(checks, request.profile.sort)
    (tags_statuses, num_down) = _tags_statuses(checks)
    pairs = list(tags_statuses.items())
    pairs.sort(key=(lambda pair: pair[0].lower()))
    channels = Channel.objects.filter(project=project)
    channels = list(channels.order_by('created'))
    hidden_checks = set()
    selected_tags = set(request.GET.getlist('tag', []))
    if selected_tags:
        for check in checks:
            if (not selected_tags.issubset(check.tags_list())):
                hidden_checks.add(check)
    search = request.GET.get('search', )
    if search:
        for check in checks:
            search_key = ('%s\n%s' % (check.name.lower(), check.code))
            if (search not in search_key):
                hidden_checks.add(check)
    show_last_duration = False
    for check in checks:
        if check.clamped_last_duration():
            show_last_duration = True
            break
    ctx = {'page': 'checks', 'rw': rw, 'checks': checks, 'channels': channels, 'num_down': num_down, 'tags': pairs, 'ping_endpoint': settings.PING_ENDPOINT, 'timezones': pytz.all_timezones, 'project': project, 'num_available': project.num_checks_available(), 'sort': request.profile.sort, 'selected_tags': selected_tags, 'search': search, 'hidden_checks': hidden_checks, 'show_last_duration': show_last_duration}
    return render(request, 'front/my_checks.html', ctx)