First commit

This commit is contained in:
Saufi
2026-05-18 08:56:23 +08:00
commit fd3d3a4d2b
147 changed files with 22099 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\AuditLog;
use App\Models\Category;
use App\Models\ChatLog;
use App\Models\Document;
use App\Models\DocumentVersion;
use App\Models\KnowledgeItem;
use App\Services\Ollama\OllamaService;
use App\Services\Qdrant\QdrantService;
use Illuminate\View\View;
class DashboardController extends Controller
{
public function index(
OllamaService $ollamaService,
QdrantService $qdrantService
): View {
$stats = [
'total_documents' => 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'));
}
}