mirror of
https://github.com/kjanat/livegraphs-django.git
synced 2026-01-16 12:12:10 +01:00
Implement data integration tasks with Celery, including periodic fetching and manual refresh of chat data; add utility functions for data processing and transcript handling; create views and URLs for manual data refresh; establish Redis and Celery configuration; enhance error handling and logging; introduce scripts for data cleanup and fixing dashboard data; update documentation for Redis and Celery setup and troubleshooting.
This commit is contained in:
@ -5,18 +5,55 @@ from django.contrib import admin
|
||||
from .models import ChatSession, Dashboard, DataSource
|
||||
|
||||
|
||||
@admin.register(DataSource)
|
||||
class DataSourceAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "company", "uploaded_at", "get_session_count")
|
||||
list_display = (
|
||||
"name",
|
||||
"company",
|
||||
"uploaded_at",
|
||||
"get_external_source",
|
||||
"get_session_count",
|
||||
)
|
||||
list_filter = ("company", "uploaded_at")
|
||||
search_fields = ("name", "description", "company__name")
|
||||
ordering = ("-uploaded_at",)
|
||||
readonly_fields = ("get_external_data_status",)
|
||||
|
||||
fieldsets = (
|
||||
(None, {"fields": ("name", "description", "company")}),
|
||||
(
|
||||
"Data Source",
|
||||
{
|
||||
"fields": ("file", "external_source"),
|
||||
"description": "Either upload a file OR select an external data source. Not both.",
|
||||
},
|
||||
),
|
||||
(
|
||||
"Stats",
|
||||
{
|
||||
"fields": ("get_external_data_status",),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
@admin.display(description="Sessions")
|
||||
def get_session_count(self, obj):
|
||||
return obj.chat_sessions.count()
|
||||
|
||||
get_session_count.short_description = "Sessions"
|
||||
@admin.display(description="External Source")
|
||||
def get_external_source(self, obj):
|
||||
if obj.external_source:
|
||||
return obj.external_source.name
|
||||
return "None"
|
||||
|
||||
@admin.display(description="External Data Status")
|
||||
def get_external_data_status(self, obj):
|
||||
if obj.external_source:
|
||||
return f"Last synced: {obj.external_source.last_synced or 'Never'} | Status: {obj.external_source.get_status()}"
|
||||
return "No external data source linked"
|
||||
|
||||
|
||||
@admin.register(ChatSession)
|
||||
class ChatSessionAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"session_id",
|
||||
@ -45,21 +82,18 @@ class ChatSessionAdmin(admin.ModelAdmin):
|
||||
)
|
||||
ordering = ("-start_time",)
|
||||
|
||||
@admin.display(
|
||||
description="Company",
|
||||
ordering="data_source__company__name",
|
||||
)
|
||||
def get_company(self, obj):
|
||||
return obj.data_source.company.name
|
||||
|
||||
get_company.short_description = "Company"
|
||||
get_company.admin_order_field = "data_source__company__name"
|
||||
|
||||
|
||||
@admin.register(Dashboard)
|
||||
class DashboardAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "company", "created_at", "updated_at")
|
||||
list_filter = ("company", "created_at")
|
||||
search_fields = ("name", "description", "company__name")
|
||||
filter_horizontal = ("data_sources",)
|
||||
ordering = ("-updated_at",)
|
||||
|
||||
|
||||
admin.site.register(DataSource, DataSourceAdmin)
|
||||
admin.site.register(ChatSession, ChatSessionAdmin)
|
||||
admin.site.register(Dashboard, DashboardAdmin)
|
||||
|
||||
Reference in New Issue
Block a user