refactor(ocr): rename ocr_last_processed to textExtractionLastProcessed

This commit is contained in:
Elian Doran
2026-04-01 16:26:16 +03:00
parent 5846df7d02
commit 38f6fb5a7f
4 changed files with 19 additions and 19 deletions

View File

@@ -108,7 +108,7 @@ CREATE TABLE IF NOT EXISTS "blobs" (
`blobId` TEXT NOT NULL,
`content` TEXT NULL DEFAULT NULL,
`textRepresentation` TEXT DEFAULT NULL,
`ocr_last_processed` TEXT DEFAULT NULL,
`textExtractionLastProcessed` TEXT DEFAULT NULL,
`dateModified` TEXT NOT NULL,
`utcDateModified` TEXT NOT NULL,
PRIMARY KEY(`blobId`)

View File

@@ -14,15 +14,15 @@ const MIGRATIONS: (SqlMigration | JsMigration)[] = [
ALTER TABLE blobs ADD COLUMN textRepresentation TEXT DEFAULT NULL;
-- Add OCR last processed timestamp to blobs table
ALTER TABLE blobs ADD COLUMN ocr_last_processed TEXT DEFAULT NULL;
ALTER TABLE blobs ADD COLUMN textExtractionLastProcessed TEXT DEFAULT NULL;
-- Create index for text representation searches
CREATE INDEX IF NOT EXISTS idx_blobs_textRepresentation
ON blobs (textRepresentation);
-- Create index for OCR last processed timestamp
CREATE INDEX IF NOT EXISTS idx_blobs_ocr_last_processed
ON blobs (ocr_last_processed);
CREATE INDEX IF NOT EXISTS idx_blobs_textExtractionLastProcessed
ON blobs (textExtractionLastProcessed);
`
},
// Add missing database indices for query performance

View File

@@ -570,16 +570,16 @@ async function getNoteOCRText(req: Request, res: Response) {
if (note.blobId) {
const result = sql.getRow<{
textRepresentation: string | null;
ocr_last_processed: string | null;
textExtractionLastProcessed: string | null;
}>(`
SELECT textRepresentation, ocr_last_processed
SELECT textRepresentation, textExtractionLastProcessed
FROM blobs
WHERE blobId = ?
`, [note.blobId]);
if (result) {
ocrText = result.textRepresentation;
extractedAt = result.ocr_last_processed;
extractedAt = result.textExtractionLastProcessed;
}
}

View File

@@ -27,7 +27,7 @@ export interface OCRProcessingOptions {
interface OCRBlobRow {
blobId: string;
textRepresentation: string;
ocr_last_processed?: string;
textExtractionLastProcessed?: string;
}
/**
@@ -236,7 +236,7 @@ class OCRService {
sql.execute(`
UPDATE blobs SET
textRepresentation = ?,
ocr_last_processed = ?
textExtractionLastProcessed = ?
WHERE blobId = ?
`, [
ocrResult.text,
@@ -563,9 +563,9 @@ class OCRService {
try {
const blobInfo = sql.getRow<{
utcDateModified: string;
ocr_last_processed: string | null;
textExtractionLastProcessed: string | null;
}>(`
SELECT utcDateModified, ocr_last_processed
SELECT utcDateModified, textExtractionLastProcessed
FROM blobs
WHERE blobId = ?
`, [blobId]);
@@ -575,13 +575,13 @@ class OCRService {
}
// If OCR was never processed, it needs processing
if (!blobInfo.ocr_last_processed) {
if (!blobInfo.textExtractionLastProcessed) {
return true;
}
// If blob was modified after last OCR processing, it needs re-processing
const blobModified = new Date(blobInfo.utcDateModified);
const lastOcrProcessed = new Date(blobInfo.ocr_last_processed);
const lastOcrProcessed = new Date(blobInfo.textExtractionLastProcessed);
return blobModified > lastOcrProcessed;
} catch (error) {
@@ -591,7 +591,7 @@ class OCRService {
}
/**
* Invalidate OCR results for a blob (clear textRepresentation and ocr_last_processed)
* Invalidate OCR results for a blob (clear textRepresentation and textExtractionLastProcessed)
*/
invalidateOCRResult(blobId: string): void {
if (!blobId) {
@@ -602,7 +602,7 @@ class OCRService {
sql.execute(`
UPDATE blobs SET
textRepresentation = NULL,
ocr_last_processed = NULL
textExtractionLastProcessed = NULL
WHERE blobId = ?
`, [blobId]);
@@ -653,8 +653,8 @@ class OCRService {
AND n.isDeleted = 0
AND n.blobId IS NOT NULL
AND (
b.ocr_last_processed IS NULL
OR b.utcDateModified > b.ocr_last_processed
b.textExtractionLastProcessed IS NULL
OR b.utcDateModified > b.textExtractionLastProcessed
)
`);
@@ -693,8 +693,8 @@ class OCRService {
AND a.isDeleted = 0
AND a.blobId IS NOT NULL
AND (
b.ocr_last_processed IS NULL
OR b.utcDateModified > b.ocr_last_processed
b.textExtractionLastProcessed IS NULL
OR b.utcDateModified > b.textExtractionLastProcessed
)
`);