<commit_before>from django.contrib.sites.shortcuts import get_current_site
from django.shortcuts import get_object_or_404, render

from job_board.models.category import Category
from job_board.models.job import Job


def categories_index(request):
    categories = Category.objects.filter(site_id=get_current_site(request).id)
    title = 'Categories'
    context = {'categories': categories, 'title': title}
    return render(request, 'job_board/categories_index.html', context)


def categories_show(request, category_id):
    category = get_object_or_404(
                   Category,
                   pk=category_id,
                   site_id=get_current_site(request).id
    )<commit_msg>Filter categories with no active jobs<commit_after>from django.contrib.sites.shortcuts import get_current_site
from django.shortcuts import get_object_or_404, render

from job_board.models.category import Category
from job_board.models.job import Job


def categories_index(request):
    categories = Category.objects.filter(site_id=get_current_site(request).id)

    for c in categories:
        if len(c.active_jobs()) == 0:
            categories = categories.exclude(id=c.id)

    title = 'Categories'
    context = {'categories': categories, 'title': title}
    return render(request, 'job_board/categories_index.html', context)


def categories_show(request, category_id):
    category = get_object_or_404(
                   Category,
                   pk=category_id,
                   site_id=get_current_site(request).id
    )
{'fraction_non_alphanumeric': 0.08670143415906127, 'fraction_numerical': 0.00847457627118644, 'mean_word_length': 3.595808383233533, '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': '5082897', 'n_tokens_mistral': 456, 'n_tokens_neox': 421, 'n_words': 94}