adsads
All checks were successful
Deploy / deploy-staging (push) Successful in 6s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-02 02:06:52 +02:00
parent 6cbf76918c
commit 44815f9c95
2 changed files with 33 additions and 0 deletions

View File

@@ -1229,6 +1229,7 @@
const data = await request(`${apiBase}/projects/${encodeURIComponent(projectKey)}/ocr-preview`, { const data = await request(`${apiBase}/projects/${encodeURIComponent(projectKey)}/ocr-preview`, {
method: 'POST', method: 'POST',
body, body,
timeoutMs: 45000,
}); });
setOcrPreview(normalizeOcrPreview(data)); setOcrPreview(normalizeOcrPreview(data));
setMessage('OCR-Ergebnis geladen. Bei Bedarf direkt speichern.'); setMessage('OCR-Ergebnis geladen. Bei Bedarf direkt speichern.');

View File

@@ -102,6 +102,7 @@ final class Router
$projectKey = $matches[1]; $projectKey = $matches[1];
$resource = trim((string) ($matches[2] ?? ''), '/'); $resource = trim((string) ($matches[2] ?? ''), '/');
$this->applyRouteRuntimeGuards($resource);
if ($resource === 'schema-status' && $method === 'GET') { if ($resource === 'schema-status' && $method === 'GET') {
$this->respond(['data' => $this->simpleSchemaStatus()]); $this->respond(['data' => $this->simpleSchemaStatus()]);
@@ -188,7 +189,19 @@ final class Router
throw new ApiException('Feld image fehlt.', 422); throw new ApiException('Feld image fehlt.', 422);
} }
$ocrStartedAt = microtime(true);
$this->debug->add('ocr.preview.start', [
'project_key' => $projectKey,
'file_name' => $_FILES['image']['name'] ?? null,
'file_size' => $_FILES['image']['size'] ?? null,
]);
$preview = $this->ocr->preview($_FILES['image'], array_merge($_POST, ['project_key' => $projectKey])); $preview = $this->ocr->preview($_FILES['image'], array_merge($_POST, ['project_key' => $projectKey]));
$this->debug->add('ocr.preview.end', [
'project_key' => $projectKey,
'duration_ms' => round((microtime(true) - $ocrStartedAt) * 1000, 2),
'confidence' => $preview['confidence'] ?? null,
'flags' => is_array($preview['flags'] ?? null) ? $preview['flags'] : [],
]);
Http::json(['data' => $preview], 201); Http::json(['data' => $preview], 201);
} }
@@ -2352,6 +2365,25 @@ final class Router
]); ]);
} }
private function applyRouteRuntimeGuards(string $resource): void
{
$normalized = trim(strtolower($resource));
$timeLimit = match ($normalized) {
'ocr-preview' => 45,
'measurements-import', 'legacy-fx-migrate', 'sql-import' => 60,
default => 15,
};
if (function_exists('set_time_limit')) {
@set_time_limit($timeLimit);
}
$this->debug->add('runtime.route_guards', [
'resource' => $resource,
'time_limit_sec' => $timeLimit,
]);
}
private function releaseSessionLock(): void private function releaseSessionLock(): void
{ {
if (PHP_SAPI === 'cli') { if (PHP_SAPI === 'cli') {