from django.contrib import admin
from .models import AnalysisRun, ClusterResult, EntityProfile, ClusterFeature


@admin.register(AnalysisRun)
class AnalysisRunAdmin(admin.ModelAdmin):
    list_display = ('id', 'created_at', 'status', 'csv_glob', 'entity_count', 'cluster_count')
    list_filter = ('status', 'created_at')
    ordering = ('-created_at',)


@admin.register(ClusterResult)
class ClusterResultAdmin(admin.ModelAdmin):
    list_display = ('run', 'cluster_label', 'size', 'noise_ratio', 'silhouette_score')
    list_filter = ('run',)


@admin.register(EntityProfile)
class EntityProfileAdmin(admin.ModelAdmin):
    list_display = ('run', 'entity_value', 'cluster_label', 'embedding_x', 'embedding_y')
    list_filter = ('run', 'cluster_label')
    search_fields = ('entity_value',)


@admin.register(ClusterFeature)
class ClusterFeatureAdmin(admin.ModelAdmin):
    list_display = ('cluster', 'feature_name', 'mean', 'std', 'distinguishing_score')
    list_filter = ('cluster__run',)
    ordering = ('-distinguishing_score',)
