TenantAtlas/apps/platform/app/Services/Evidence/Sources/OperationsSummarySource.php
ahmido ce0615a9c1 Spec 182: relocate Laravel platform to apps/platform (#213)
## Summary
- move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling
- update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location
- add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior

## Validation
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation`
- integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404`

## Remaining Rollout Checks
- validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout
- confirm web, queue, and scheduler processes all start from the expected working directory in staging/production
- verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #213
2026-04-08 08:40:47 +00:00

63 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Services\Evidence\Sources;
use App\Models\OperationRun;
use App\Models\Tenant;
use App\Services\Evidence\Contracts\EvidenceSourceProvider;
use App\Support\Evidence\EvidenceCompletenessState;
use App\Support\OperationRunOutcome;
final class OperationsSummarySource implements EvidenceSourceProvider
{
public function key(): string
{
return 'operations_summary';
}
public function collect(Tenant $tenant): array
{
$runs = OperationRun::query()
->where('tenant_id', (int) $tenant->getKey())
->where('created_at', '>=', now()->subDays(30))
->latest('created_at')
->get();
$latest = $runs->max('created_at');
return [
'dimension_key' => $this->key(),
'state' => $runs->isEmpty() ? EvidenceCompletenessState::Missing->value : EvidenceCompletenessState::Complete->value,
'required' => true,
'source_kind' => 'operation_rollup',
'source_record_type' => OperationRun::class,
'source_record_id' => null,
'source_fingerprint' => hash('sha256', implode('|', $runs->pluck('run_identity_hash')->all())),
'measured_at' => $latest,
'freshness_at' => $latest,
'summary_payload' => [
'operation_count' => $runs->count(),
'failed_count' => $runs->where('outcome', OperationRunOutcome::Failed->value)->count(),
'partial_count' => $runs->where('outcome', OperationRunOutcome::PartiallySucceeded->value)->count(),
'entries' => $runs->map(static fn (OperationRun $run): array => [
'id' => (int) $run->getKey(),
'type' => (string) $run->type,
'status' => (string) $run->status,
'outcome' => (string) $run->outcome,
'initiator_name' => $run->user?->name,
'started_at' => $run->started_at?->toIso8601String(),
'completed_at' => $run->completed_at?->toIso8601String(),
])->all(),
],
'fingerprint_payload' => [
'count' => $runs->count(),
'latest' => $latest?->format(DATE_ATOM),
'hashes' => $runs->pluck('run_identity_hash')->values()->all(),
],
'sort_order' => 50,
];
}
}