Wire Celery Beat periodic sync with ingestion run tracking
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from django.contrib import messages
|
||||
from django.db.models import Count
|
||||
|
||||
from apps.providers.registry import get_default_provider_namespace
|
||||
|
||||
@ -20,7 +21,11 @@ class IngestionRunAdmin(admin.ModelAdmin):
|
||||
"job_type",
|
||||
"status",
|
||||
"records_processed",
|
||||
"records_created",
|
||||
"records_updated",
|
||||
"records_failed",
|
||||
"error_count",
|
||||
"short_error_summary",
|
||||
"started_at",
|
||||
"finished_at",
|
||||
)
|
||||
@ -38,6 +43,7 @@ class IngestionRunAdmin(admin.ModelAdmin):
|
||||
"records_created",
|
||||
"records_updated",
|
||||
"records_failed",
|
||||
"error_summary",
|
||||
"context",
|
||||
"raw_payload",
|
||||
"created_at",
|
||||
@ -79,6 +85,20 @@ class IngestionRunAdmin(admin.ModelAdmin):
|
||||
count += 1
|
||||
self.message_user(request, f"Queued {count} retry task(s).", level=messages.SUCCESS)
|
||||
|
||||
def get_queryset(self, request):
|
||||
queryset = super().get_queryset(request)
|
||||
return queryset.annotate(_error_count=Count("errors"))
|
||||
|
||||
@admin.display(ordering="_error_count", description="Errors")
|
||||
def error_count(self, obj):
|
||||
return getattr(obj, "_error_count", 0)
|
||||
|
||||
@admin.display(description="Error summary")
|
||||
def short_error_summary(self, obj):
|
||||
if not obj.error_summary:
|
||||
return "-"
|
||||
return (obj.error_summary[:90] + "...") if len(obj.error_summary) > 90 else obj.error_summary
|
||||
|
||||
|
||||
@admin.register(IngestionError)
|
||||
class IngestionErrorAdmin(admin.ModelAdmin):
|
||||
|
||||
Reference in New Issue
Block a user