<commit_before># -*- coding: utf-8 -*-

from codespeed.models import (Project, Revision, Executable, Benchmark, Branch,
                              Result, Environment, Report)

from django.contrib import admin


class ProjectAdmin(admin.ModelAdmin):
    list_display = ('name', 'repo_type', 'repo_path', 'track')

admin.site.register(Project, ProjectAdmin)


class BranchAdmin(admin.ModelAdmin):
    list_display = ('name', 'project')

admin.site.register(Branch, BranchAdmin)


class RevisionAdmin(admin.ModelAdmin):
    list_display = ('commitid', 'branch', 'tag', 'date')
    list_filter = ('branch', 'tag', 'date')
    search_fields = ('commitid', 'tag')

admin.site.register(Revision, RevisionAdmin)


class ExecutableAdmin(admin.ModelAdmin):
    list_display = ('name', 'description', 'id', 'project')
    search_fields = ('name', 'description', 'project')

admin.site.register(Executable, ExecutableAdmin)


class BenchmarkAdmin(admin.ModelAdmin):
    list_display = ('name', 'benchmark_type', 'description', 'units_title',
                    'units', 'lessisbetter', 'default_on_comparison')
    ordering = ['name']
    search_fields = ('name', 'description')

admin.site.register(Benchmark, BenchmarkAdmin)


class EnvironmentAdmin(admin.ModelAdmin):
    list_display = ('name', 'cpu', 'memory', 'os', 'kernel')
    search_fields = ('name', 'cpu', 'memory', 'os', 'kernel')

admin.site.register(Environment, EnvironmentAdmin)


class ResultAdmin(admin.ModelAdmin):
    list_display = ('revision', 'benchmark', 'executable', 'environment',
                    'value', 'date', 'environment')
    list_filter = ('date', 'environment', 'executable', 'benchmark')

admin.site.register(Result, ResultAdmin)


class ReportAdmin(admin.ModelAdmin):
    list_display = ('revision', 'summary', 'colorcode')
    ordering = ['-revision']

admin.site.register(Report, ReportAdmin)<commit_msg>New admin action for Reports: recalculate<commit_after># -*- coding: utf-8 -*-

from codespeed.models import (Project, Revision, Executable, Benchmark, Branch,
                              Result, Environment, Report)

from django.contrib import admin


class ProjectAdmin(admin.ModelAdmin):
    list_display = ('name', 'repo_type', 'repo_path', 'track')

admin.site.register(Project, ProjectAdmin)


class BranchAdmin(admin.ModelAdmin):
    list_display = ('name', 'project')

admin.site.register(Branch, BranchAdmin)


class RevisionAdmin(admin.ModelAdmin):
    list_display = ('commitid', 'branch', 'tag', 'date')
    list_filter = ('branch', 'tag', 'date')
    search_fields = ('commitid', 'tag')

admin.site.register(Revision, RevisionAdmin)


class ExecutableAdmin(admin.ModelAdmin):
    list_display = ('name', 'description', 'id', 'project')
    search_fields = ('name', 'description', 'project')

admin.site.register(Executable, ExecutableAdmin)


class BenchmarkAdmin(admin.ModelAdmin):
    list_display = ('name', 'benchmark_type', 'description', 'units_title',
                    'units', 'lessisbetter', 'default_on_comparison')
    ordering = ['name']
    search_fields = ('name', 'description')

admin.site.register(Benchmark, BenchmarkAdmin)


class EnvironmentAdmin(admin.ModelAdmin):
    list_display = ('name', 'cpu', 'memory', 'os', 'kernel')
    search_fields = ('name', 'cpu', 'memory', 'os', 'kernel')

admin.site.register(Environment, EnvironmentAdmin)


class ResultAdmin(admin.ModelAdmin):
    list_display = ('revision', 'benchmark', 'executable', 'environment',
                    'value', 'date', 'environment')
    list_filter = ('date', 'environment', 'executable', 'benchmark')

admin.site.register(Result, ResultAdmin)


def recalculate_report(modeladmin, request, queryset):
    for report in queryset:
        report.save()
recalculate_report.short_description = "Recalculate reports"

class ReportAdmin(admin.ModelAdmin):
    list_display = ('revision', 'summary', 'colorcode')
    ordering = ['-revision']
    actions = [recalculate_report]

admin.site.register(Report, ReportAdmin)
{'fraction_non_alphanumeric': 0.1532137518684604, 'fraction_numerical': 0.0004982561036372695, 'mean_word_length': 4.695035460992908, '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': '3053219', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1166, 'n_words': 264}