Document::count(), 'active_documents' => Document::where('is_active', true)->count(), 'processing_documents' => Document::where('status', 'processing')->count(), 'failed_documents' => Document::whereIn('status', ['failed', 'extraction_failed'])->count(), 'total_categories' => Category::where('is_active', true)->count(), 'total_knowledge_items' => KnowledgeItem::where('is_active', true)->count(), 'total_chats_today' => ChatLog::whereDate('created_at', today())->count(), 'unanswered_chats' => ChatLog::where('has_answer', false)->count(), 'flagged_chats' => ChatLog::where('is_flagged', true)->count(), ]; $recentActivity = AuditLog::with('user') ->latest('created_at') ->limit(10) ->get(); $recentChats = ChatLog::with('category') ->latest() ->limit(5) ->get(); // Health check (cache 60 saat supaya tidak lambat setiap load) $health = cache()->remember('service_health', 60, function () use ($ollamaService, $qdrantService) { return [ 'ollama' => $ollamaService->healthCheck(), 'qdrant' => $qdrantService->healthCheck(), ]; }); return view('admin.dashboard', compact('stats', 'recentActivity', 'recentChats', 'health')); } }