<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseServerError
from django.template import Context, loader, TemplateDoesNotExist
from django.shortcuts import render
from django.views.decorators.csrf import requires_csrf_token
from guardian.shortcuts import get_objects_for_user

from .clusters.models import Cluster
from .jobs.models import SparkJob


@login_required
def dashboard(request):
    # allowed filters for clusters
    default_filter = 'active'
    clusters_filters = ['active', 'terminated', 'failed', 'all']

    # the cluster filter defaults to active ones
    clusters_shown = request.GET.get('clusters', default_filter)
    if clusters_shown not in clusters_filters:
        clusters_shown = default_filter

    # get the model manager method depending on the cluster filter
    # and call it to get the base queryset
    clusters = get_objects_for_user(
        request.user,
        'clusters.view_cluster',
        getattr(Cluster.objects, clusters_shown)().order_by('-start_date'),
        use_groups=False,
        with_superuser=False,
    )

    spark_jobs = get_objects_for_user(
        request.user,
        'jobs.view_sparkjob',
        SparkJob.objects.all().order_by('start_date'),
        use_groups=False,
        with_superuser=False,
    )

    context = {
        'clusters': clusters,<commit_msg>Bug 1316048 - Show Spark jobs in descending order on dashboard<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseServerError
from django.template import Context, loader, TemplateDoesNotExist
from django.shortcuts import render
from django.views.decorators.csrf import requires_csrf_token
from guardian.shortcuts import get_objects_for_user

from .clusters.models import Cluster
from .jobs.models import SparkJob


@login_required
def dashboard(request):
    # allowed filters for clusters
    default_filter = 'active'
    clusters_filters = ['active', 'terminated', 'failed', 'all']

    # the cluster filter defaults to active ones
    clusters_shown = request.GET.get('clusters', default_filter)
    if clusters_shown not in clusters_filters:
        clusters_shown = default_filter

    # get the model manager method depending on the cluster filter
    # and call it to get the base queryset
    clusters = get_objects_for_user(
        request.user,
        'clusters.view_cluster',
        getattr(Cluster.objects, clusters_shown)().order_by('-start_date'),
        use_groups=False,
        with_superuser=False,
    )

    spark_jobs = get_objects_for_user(
        request.user,
        'jobs.view_sparkjob',
        SparkJob.objects.all().order_by('-start_date'),
        use_groups=False,
        with_superuser=False,
    )

    context = {
        'clusters': clusters,
{'fraction_non_alphanumeric': 0.07868649318463444, 'fraction_numerical': 0.004646840148698885, 'mean_word_length': 3.619456366237482, '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': '7005391', 'n_tokens_mistral': 943, 'n_tokens_neox': 895, 'n_words': 280}