chore: cleanup dead code + format with Pint
- Remove unused FeaturesController (empty stubs, no routes) - Remove ConvertSpatialFile CLI command (unused; service used in LayerManager) - Remove MigrateGeojsonToFeatures CLI command (one-shot migration, not referenced) - Remove .claude/worktrees/ (11 old agent worktrees from June) - Apply Laravel Pint formatting across 219 files (style only, no functional changes) Tests: 101 passing (319 assertions) API routes: unchanged (8 routes intact)
This commit is contained in:
@@ -8,16 +8,15 @@ use App\Models\Inspection;
|
||||
use App\Models\Issue;
|
||||
use App\Models\Media;
|
||||
use App\Models\Phase;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProgressSnapshot;
|
||||
use App\Models\Project;
|
||||
use App\Models\Task;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ReportGenerator
|
||||
{
|
||||
protected Project $project;
|
||||
|
||||
protected ReportFilters $filters;
|
||||
|
||||
public function __construct(Project $project, ReportFilters $filters)
|
||||
@@ -82,7 +81,7 @@ class ReportGenerator
|
||||
->with(['layers.features'])
|
||||
->get();
|
||||
|
||||
$allFeatures = $phases->flatMap(fn($p) => $p->layers->flatMap(fn($l) => $l->features));
|
||||
$allFeatures = $phases->flatMap(fn ($p) => $p->layers->flatMap(fn ($l) => $l->features));
|
||||
$completedFeatures = $allFeatures->where('status', 'completed')->count();
|
||||
|
||||
$inspectionsQuery = Inspection::where('project_id', $this->project->id);
|
||||
@@ -136,8 +135,8 @@ class ReportGenerator
|
||||
->get();
|
||||
|
||||
return $phases->map(function ($phase) {
|
||||
$phaseFeatures = $phase->layers->flatMap(fn($l) => $l->features);
|
||||
|
||||
$phaseFeatures = $phase->layers->flatMap(fn ($l) => $l->features);
|
||||
|
||||
return [
|
||||
'id' => $phase->id,
|
||||
'name' => $phase->name,
|
||||
@@ -158,7 +157,7 @@ class ReportGenerator
|
||||
'is_on_track' => $phase->is_on_track,
|
||||
'features_count' => $phaseFeatures->count(),
|
||||
'completed_features' => $phaseFeatures->where('status', 'completed')->count(),
|
||||
'layers' => $phase->layers->map(fn($l) => [
|
||||
'layers' => $phase->layers->map(fn ($l) => [
|
||||
'id' => $l->id,
|
||||
'name' => $l->name,
|
||||
'features_count' => $l->features->count(),
|
||||
@@ -169,7 +168,7 @@ class ReportGenerator
|
||||
|
||||
protected function buildFeaturesData(): array
|
||||
{
|
||||
$query = Feature::whereHas('layer.phase', fn($q) => $q->where('project_id', $this->project->id))
|
||||
$query = Feature::whereHas('layer.phase', fn ($q) => $q->where('project_id', $this->project->id))
|
||||
->with(['layer.phase', 'template', 'inspections', 'issues']);
|
||||
|
||||
// Apply date filter on feature created_at if date range provided
|
||||
@@ -179,7 +178,7 @@ class ReportGenerator
|
||||
|
||||
return $features->map(function ($feature) {
|
||||
$lastInspection = $feature->inspections->sortByDesc('created_at')->first();
|
||||
|
||||
|
||||
return [
|
||||
'id' => $feature->id,
|
||||
'name' => $feature->name,
|
||||
@@ -227,7 +226,7 @@ class ReportGenerator
|
||||
'date' => $inspection->created_at->format('d/m/Y H:i'),
|
||||
'status' => $inspection->status,
|
||||
'result' => $inspection->result,
|
||||
'result_label' => match($inspection->result) {
|
||||
'result_label' => match ($inspection->result) {
|
||||
'pass' => 'Aprobada',
|
||||
'fail' => 'Fallida',
|
||||
'conditional' => 'Condicional',
|
||||
@@ -256,7 +255,7 @@ class ReportGenerator
|
||||
'feature' => $issue->feature?->name ?? '—',
|
||||
'phase' => $issue->feature?->layer?->phase?->name ?? '—',
|
||||
'priority' => $issue->priority,
|
||||
'priority_label' => match($issue->priority) {
|
||||
'priority_label' => match ($issue->priority) {
|
||||
'low' => 'Baja',
|
||||
'medium' => 'Media',
|
||||
'high' => 'Alta',
|
||||
@@ -264,7 +263,7 @@ class ReportGenerator
|
||||
default => ucfirst($issue->priority ?? ''),
|
||||
},
|
||||
'status' => $issue->status,
|
||||
'status_label' => match($issue->status) {
|
||||
'status_label' => match ($issue->status) {
|
||||
'open' => 'Abierta',
|
||||
'in_review' => 'En revisión',
|
||||
'closed' => 'Cerrada',
|
||||
@@ -308,7 +307,7 @@ class ReportGenerator
|
||||
'actual_hours' => $task->actual_hours,
|
||||
'progress' => $task->progress,
|
||||
'is_overdue' => $task->is_overdue,
|
||||
'subtasks' => $task->subtasks->map(fn($st) => [
|
||||
'subtasks' => $task->subtasks->map(fn ($st) => [
|
||||
'id' => $st->id,
|
||||
'title' => $st->title,
|
||||
'status' => $st->status,
|
||||
@@ -341,8 +340,10 @@ class ReportGenerator
|
||||
// Filter by project in PHP (polymorphic complexity)
|
||||
$filtered = $media->filter(function ($m) {
|
||||
$mediable = $m->mediable;
|
||||
if (!$mediable) return false;
|
||||
|
||||
if (! $mediable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($mediable instanceof Phase) {
|
||||
return $mediable->project_id === $this->project->id;
|
||||
}
|
||||
@@ -358,6 +359,7 @@ class ReportGenerator
|
||||
if ($mediable instanceof Task) {
|
||||
return $mediable->project_id === $this->project->id;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -398,9 +400,9 @@ class ReportGenerator
|
||||
'spi' => $phase->spi,
|
||||
'is_on_track' => $phase->is_on_track,
|
||||
];
|
||||
})->filter(fn($p) => $p['planned_start'] || $p['planned_end'])->toArray();
|
||||
})->filter(fn ($p) => $p['planned_start'] || $p['planned_end'])->toArray();
|
||||
|
||||
$featureDeviations = Feature::whereHas('layer.phase', fn($q) => $q->where('project_id', $this->project->id))
|
||||
$featureDeviations = Feature::whereHas('layer.phase', fn ($q) => $q->where('project_id', $this->project->id))
|
||||
->whereNotNull('planned_end')
|
||||
->with(['layer.phase'])
|
||||
->get()
|
||||
@@ -428,12 +430,12 @@ class ReportGenerator
|
||||
'phases' => $phaseDeviations,
|
||||
'features' => $featureDeviations,
|
||||
'summary' => [
|
||||
'phases_delayed' => count(array_filter($phaseDeviations, fn($p) => ($p['end_deviation'] ?? 0) > 0)),
|
||||
'phases_early' => count(array_filter($phaseDeviations, fn($p) => ($p['end_deviation'] ?? 0) < 0)),
|
||||
'phases_on_time' => count(array_filter($phaseDeviations, fn($p) => ($p['end_deviation'] ?? 0) === 0)),
|
||||
'features_delayed' => count(array_filter($featureDeviations, fn($f) => ($f['end_deviation'] ?? 0) > 0)),
|
||||
'features_early' => count(array_filter($featureDeviations, fn($f) => ($f['end_deviation'] ?? 0) < 0)),
|
||||
'features_on_time' => count(array_filter($featureDeviations, fn($f) => ($f['end_deviation'] ?? 0) === 0)),
|
||||
'phases_delayed' => count(array_filter($phaseDeviations, fn ($p) => ($p['end_deviation'] ?? 0) > 0)),
|
||||
'phases_early' => count(array_filter($phaseDeviations, fn ($p) => ($p['end_deviation'] ?? 0) < 0)),
|
||||
'phases_on_time' => count(array_filter($phaseDeviations, fn ($p) => ($p['end_deviation'] ?? 0) === 0)),
|
||||
'features_delayed' => count(array_filter($featureDeviations, fn ($f) => ($f['end_deviation'] ?? 0) > 0)),
|
||||
'features_early' => count(array_filter($featureDeviations, fn ($f) => ($f['end_deviation'] ?? 0) < 0)),
|
||||
'features_on_time' => count(array_filter($featureDeviations, fn ($f) => ($f['end_deviation'] ?? 0) === 0)),
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -442,7 +444,7 @@ class ReportGenerator
|
||||
{
|
||||
// Get snapshots for this project's phases and features
|
||||
$phaseIds = $this->project->phases->pluck('id')->toArray();
|
||||
$featureIds = Feature::whereHas('layer.phase', fn($q) => $q->whereIn('phase_id', $phaseIds))
|
||||
$featureIds = Feature::whereHas('layer.phase', fn ($q) => $q->whereIn('phase_id', $phaseIds))
|
||||
->pluck('id')->toArray();
|
||||
$taskIds = Task::where('project_id', $this->project->id)->pluck('id')->toArray();
|
||||
|
||||
@@ -475,7 +477,7 @@ class ReportGenerator
|
||||
|
||||
foreach ($grouped as $date => $snaps) {
|
||||
$dates[] = Carbon::parse($date)->format('d/m/Y');
|
||||
|
||||
|
||||
$phaseSnaps = $snaps->where('trackable_type', Phase::class);
|
||||
$featureSnaps = $snaps->where('trackable_type', Feature::class);
|
||||
$taskSnaps = $snaps->where('trackable_type', Task::class);
|
||||
@@ -523,7 +525,7 @@ class ReportGenerator
|
||||
|
||||
protected function getFeatureStatusLabel(string $status): string
|
||||
{
|
||||
return match($status) {
|
||||
return match ($status) {
|
||||
'planned' => 'Planificado',
|
||||
'started' => 'Iniciado',
|
||||
'in_progress' => 'En progreso',
|
||||
@@ -541,6 +543,7 @@ class ReportGenerator
|
||||
$bytes /= 1024;
|
||||
$i++;
|
||||
}
|
||||
return round($bytes, 1) . ' ' . $units[$i];
|
||||
|
||||
return round($bytes, 1).' '.$units[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user