feat: Phase 1 - Redis config, Dashboard cache, Report cache, N+1 fixes, observers
- Add predis/predis for Redis support - Configure cache/queue defaults to redis in config + .env.example - Create DashboardController with 60s cache for dashboard queries - Add cache (5min) to ReportController::generate() and preview() - Add FeatureObserver, InspectionObserver, IssueObserver for cache invalidation - Fix N+1 in ProjectMap (eager load template, images), TaskManager (subtasks.parentTask) - Register observers in AppServiceProvider Tests: 101 passing (319 assertions)
This commit is contained in:
+3
-37
@@ -52,47 +52,13 @@ Route::get('/', function () {
|
||||
return redirect()->route('dashboard');
|
||||
})->middleware(['auth']);
|
||||
|
||||
use App\Http\Controllers\DashboardController;
|
||||
|
||||
// Grupo de rutas protegidas por autenticación
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
|
||||
// Home: vista ligera (proyectos, tareas e incidencias del usuario + notificaciones)
|
||||
Route::get('/dashboard', function () {
|
||||
$user = Auth::user();
|
||||
|
||||
$projects = Project::accessibleBy($user)
|
||||
->with(['phases' => fn ($q) => $q->select('id', 'project_id', 'progress_percent')])
|
||||
->orderBy('name')->take(8)->get();
|
||||
$projectsCount = Project::accessibleBy($user)->count();
|
||||
|
||||
$myTasks = IssueTask::where('assigned_to', $user->id)
|
||||
->where('is_done', false)
|
||||
->with('issue.project')
|
||||
->orderByRaw('due_date IS NULL, due_date ASC')
|
||||
->take(8)->get();
|
||||
|
||||
$myTasksFromTasks = Task::where('assigned_to', $user->id)
|
||||
->where('status', '!=', 'completed')
|
||||
->with('project')
|
||||
->orderByRaw('due_date IS NULL, due_date ASC')
|
||||
->take(8)->get();
|
||||
|
||||
$myTasksCount = IssueTask::where('assigned_to', $user->id)->where('is_done', false)->count()
|
||||
+ Task::where('assigned_to', $user->id)->where('status', '!=', 'completed')->count();
|
||||
|
||||
$myIssues = Issue::where('assigned_to', $user->id)
|
||||
->whereIn('status', ['open', 'in_review'])
|
||||
->with('project')
|
||||
->latest()->take(6)->get();
|
||||
$myIssuesCount = Issue::where('assigned_to', $user->id)->whereIn('status', ['open', 'in_review'])->count();
|
||||
|
||||
$notifications = $user->notifications()->latest()->take(6)->get();
|
||||
$unreadCount = $user->unreadNotifications()->count();
|
||||
|
||||
return view('dashboard', compact(
|
||||
'user', 'projects', 'projectsCount', 'myTasks', 'myTasksFromTasks', 'myTasksCount',
|
||||
'myIssues', 'myIssuesCount', 'notifications', 'unreadCount'
|
||||
));
|
||||
})->name('dashboard');
|
||||
Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
|
||||
|
||||
Route::get('/reports/dashboard', ReportsDashboard::class)->name('reports.dashboard');
|
||||
Route::prefix('reports')->name('reports.')->group(function () {
|
||||
|
||||
Reference in New Issue
Block a user