<commit_before>from django.contrib import admin
from .models import TestView, TestResult
from .views import TestResultDisplay

class TestViewAdmin(admin.ModelAdmin):
    list_display = ('url', 'method', 'data', 'creation_time')
    search_fields = ('url', 'method', 'data')


class TestResultAdmin(admin.ModelAdmin):
    list_display = ('view', 'time', 'result_code', 'result')
    search_fields = ('view', 'result_code', 'result')

# Register models with admin site
admin.site.register(TestView, TestViewAdmin)
admin.site.register(TestResult, TestResultAdmin)

# Register additional views
admin.site.register_view('performancetests', 'Plot performance test results',
                         view=TestResultDisplay.as_view())
<commit_msg>Performance tests: display only first 100 characters of a result in admin<commit_after>from django.contrib import admin
from .models import TestView, TestResult
from .views import TestResultDisplay

def trimmed_result(obj):
    last_character = min(len(obj.result), 100)
    return "%s ..." % obj.result[:last_character]

class TestViewAdmin(admin.ModelAdmin):
    list_display = ('url', 'method', 'data', 'creation_time')
    search_fields = ('url', 'method', 'data')


class TestResultAdmin(admin.ModelAdmin):
    list_display = ('view', 'time', 'result_code', trimmed_result)
    search_fields = ('view', 'result_code', 'result')

# Register models with admin site
admin.site.register(TestView, TestViewAdmin)
admin.site.register(TestResult, TestResultAdmin)

# Register additional views
admin.site.register_view('performancetests', 'Plot performance test results',
                         view=TestResultDisplay.as_view())

{'fraction_non_alphanumeric': 0.12117576484703059, 'fraction_numerical': 0.003599280143971206, 'mean_word_length': 5.154981549815498, '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': '5619636', 'n_tokens_mistral': 478, 'n_tokens_neox': 459, 'n_words': 125}