feat(ocr): show translated progress messages during OCR processing
Some checks failed
CI / Unit & Component Tests (push) Failing after 2s
CI / Backend Unit Tests (push) Failing after 1s
CI / Unit & Component Tests (pull_request) Failing after 2s
CI / Backend Unit Tests (pull_request) Failing after 1s

Backend sends progress codes (PREPARING, LOADING, ANALYZING,
CREATING_BLOCKS:N, DONE:N, ERROR) via OcrJob.progressMessage.
Frontend translates them via Paraglide (de/en/es) and displays
below the spinner.

- V27 migration: adds progress_message column to ocr_jobs
- OcrAsyncRunner updates progress at each phase
- Poll interval reduced to 2s for snappier updates

Refs #226

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-12 23:31:23 +02:00
parent 0b0d4a7d5e
commit 971527a50e
7 changed files with 66 additions and 3 deletions

View File

@@ -47,6 +47,9 @@ public class OcrJob {
@Builder.Default
private int skippedCount = 0;
@Column(name = "progress_message")
private String progressMessage;
@Column(name = "created_by")
private UUID createdBy;

View File

@@ -37,7 +37,7 @@ public class OcrAsyncRunner {
if (job == null) return;
job.setStatus(OcrJobStatus.RUNNING);
ocrJobRepository.save(job);
updateProgress(job, "PREPARING");
OcrJobDocument jobDoc = ocrJobDocumentRepository.findByJobIdAndDocumentId(jobId, documentId)
.orElse(null);
@@ -49,9 +49,19 @@ public class OcrAsyncRunner {
Document doc = documentService.getDocumentById(documentId);
try {
processDocument(documentId, doc, userId);
updateProgress(job, "LOADING");
clearExistingBlocks(documentId);
String pdfUrl = fileService.generatePresignedUrl(doc.getFilePath());
updateProgress(job, "ANALYZING");
List<OcrBlockResult> blocks = ocrClient.extractBlocks(pdfUrl, doc.getScriptType());
updateProgress(job, "CREATING_BLOCKS:" + blocks.size());
createTranscriptionBlocks(documentId, blocks, userId, doc.getFileHash());
job.setStatus(OcrJobStatus.DONE);
job.setProcessedDocuments(1);
updateProgress(job, "DONE:" + blocks.size());
if (jobDoc != null) {
jobDoc.setStatus(OcrDocumentStatus.DONE);
ocrJobDocumentRepository.save(jobDoc);
@@ -60,13 +70,17 @@ public class OcrAsyncRunner {
log.error("OCR processing failed for document {}", documentId, e);
job.setStatus(OcrJobStatus.FAILED);
job.setErrorCount(1);
updateProgress(job, "ERROR");
if (jobDoc != null) {
jobDoc.setStatus(OcrDocumentStatus.FAILED);
jobDoc.setErrorMessage(e.getMessage());
ocrJobDocumentRepository.save(jobDoc);
}
}
}
private void updateProgress(OcrJob job, String message) {
job.setProgressMessage(message);
ocrJobRepository.save(job);
}

View File

@@ -0,0 +1 @@
ALTER TABLE ocr_jobs ADD COLUMN progress_message TEXT;