<commit_before># -*- coding: utf-8 -*-
"""elasticsearch_django model admin."""
import simplejson as json  # simplejson supports Decimal serialization
import logging

from django.contrib import admin
from django.utils.safestring import mark_safe

from .models import SearchQuery

logger = logging.getLogger(__name__)


def pprint(data):
    """
    Returns an indented HTML pretty-print version of JSON.

    Take the event_payload JSON, indent it, order the keys and then
    present it as a <code> block. That's about as good as we can get
    until someone builds a custom syntax function.

    """
    pretty = json.dumps(
        data,
        sort_keys=True,
        indent=4,
        separators=(',', ': ')
    )
    return mark_safe("<code>%s</code>" % pretty.replace(" ", "&nbsp;"))


class SearchQueryAdmin(admin.ModelAdmin):

    list_display = (
        'user',
        'index',
        'total_hits',
        'returned_',
        'min_',
        'max_',
        'reference',
        'executed_at',
    )
    list_filter = (
        'index',
    )<commit_msg>Update JSON format in admin edit view<commit_after># -*- coding: utf-8 -*-
"""elasticsearch_django model admin."""
import simplejson as json  # simplejson supports Decimal serialization
import logging

from django.contrib import admin
from django.utils.safestring import mark_safe

from .models import SearchQuery

logger = logging.getLogger(__name__)


def pprint(data):
    """
    Returns an indented HTML pretty-print version of JSON.

    Take the event_payload JSON, indent it, order the keys and then
    present it as a <code> block. That's about as good as we can get
    until someone builds a custom syntax function.

    """
    pretty = json.dumps(
        data,
        sort_keys=True,
        indent=4,
        separators=(',', ': ')
    )
    html = pretty.replace(" ", "&nbsp;").replace("\n", "<br>")
    return mark_safe("<code>%s</code>" % html)


class SearchQueryAdmin(admin.ModelAdmin):

    list_display = (
        'user',
        'index',
        'total_hits',
        'returned_',
        'min_',
        'max_',
        'reference',
        'executed_at',
    )
    list_filter = (
        'index',
    )
{'fraction_non_alphanumeric': 0.11727272727272728, 'fraction_numerical': 0.0018181818181818182, 'mean_word_length': 2.590538336052202, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '1855050', 'n_tokens_mistral': 650, 'n_tokens_neox': 637, 'n_words': 199}