<commit_before>from django.contrib.auth.models import User
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.views.generic.list_detail import object_list, object_detail

from builds.models import Build
from projects.models import Project

from taggit.models import Tag

def build_list(request, username=None, project_slug=None, tag=None):
    """Show a list of builds.
    """
    queryset = Build.objects.all()
    if username:
        user = get_object_or_404(User, username=username)
        queryset = queryset.filter(project__user=user)
    else:
        user = None
    if tag:
        tag = get_object_or_404(Tag, slug=tag)
        queryset = queryset.filter(project__tags__in=[tag.slug])
    else:
        tag = None

    if project_slug and username:
        project = Project.objects.get(user=user, slug=project_slug)
        queryset = queryset.filter(project=project)
    else:
        project = None


    return object_list(
        request,
        queryset=queryset,
        extra_context={'person': user, 'project': project, 'tag': tag},
        template_object_name='build',
    )


def build_detail(request, username, project_slug, pk):
    """Show the details of a particular build.
    """
    user = get_object_or_404(User, username=username)
    queryset = Build.objects.all()

    if project_slug and username:
        project = Project.objects.get(user=user, slug=project_slug)
        queryset = queryset.filter(project=project)
    else:
        project = None

    return object_detail(
        request,
        queryset=queryset,
        object_id=pk,
        extra_context={'user': user, 'project': project },
        template_object_name='build',
    )

<commit_msg>Fix errors on build pages.<commit_after>from django.contrib.auth.models import User
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.views.generic.list_detail import object_list, object_detail

from builds.models import Build
from projects.models import Project

from taggit.models import Tag

def build_list(request, username=None, project_slug=None, tag=None):
    """Show a list of builds.
    """
    queryset = Build.objects.all()
    user = get_object_or_404(User, username=username)
    queryset = queryset.filter(project__user=user)

    if tag:
        tag = get_object_or_404(Tag, slug=tag)
        queryset = queryset.filter(project__tags__in=[tag.slug])
    else:
        tag = None

    project = get_object_or_404(Project, user=user, slug=project_slug)
    queryset = queryset.filter(project=project)

    return object_list(
        request,
        queryset=queryset,
        extra_context={'person': user, 'project': project, 'tag': tag},
        template_object_name='build',
    )


def build_detail(request, username, project_slug, pk):
    """Show the details of a particular build.
    """
    user = get_object_or_404(User, username=username)
    project = get_object_or_404(Project, user=user, slug=project_slug)
    queryset = Build.objects.filter(project=project)

    return object_detail(
        request,
        queryset=queryset,
        object_id=pk,
        extra_context={'user': user, 'project': project },
        template_object_name='build',
    )

{'fraction_non_alphanumeric': 0.0963855421686747, 'fraction_numerical': 0.009036144578313253, 'mean_word_length': 3.428, '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': '4961285', 'n_tokens_mistral': 1005, 'n_tokens_neox': 981, 'n_words': 233}