<commit_before>from django.contrib import admin

from pythonpro.analytics.models import PageView


@admin.register(PageView)
class PageViewAdmin(admin.ModelAdmin):
    list_display = ['id', 'session', 'created']
<commit_msg>improving analytics admin<commit_after>from django.contrib import admin

from pythonpro.analytics.models import PageView


@admin.register(PageView)
class PageViewAdmin(admin.ModelAdmin):
    def get_session_user(self, obj, *args, **kwargs):
        return obj.session.user

    def get_path(self, obj, *args, **kwargs):
        return obj.meta.get('PATH_INFO')

    def has_delete_permission(self, request, obj=None):
        return False

    def has_change_permission(self, request, obj=None):
        return False

    def has_add_permission(self, request, obj=None):
        return False

    get_session_user.short_description = 'Usuário'
    get_path.short_description = 'Destino'
    list_display = ['id', 'get_path', 'session', 'get_session_user', 'created']
    list_filter = ['session__user']

{'fraction_non_alphanumeric': 0.10992217898832685, 'fraction_numerical': 0.0, 'mean_word_length': 4.562162162162162, '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': '5910579', 'n_tokens_mistral': 314, 'n_tokens_neox': 305, 'n_words': 72}