diff --git a/RMuseum/DbContext/RMuseumDbContext.cs b/RMuseum/DbContext/RMuseumDbContext.cs index c451f365..8195bf1e 100644 --- a/RMuseum/DbContext/RMuseumDbContext.cs +++ b/RMuseum/DbContext/RMuseumDbContext.cs @@ -548,5 +548,10 @@ namespace RMuseum.DbContext /// public DbSet PDFGanjoorLinks { get; set; } + /// + /// OCR Queue Items + /// + public DbSet OCRQueuedItems { get; set; } + } } diff --git a/RMuseum/Models/PDFLibrary/OCRQueue.cs b/RMuseum/Models/PDFLibrary/OCRQueue.cs new file mode 100644 index 00000000..e98462a3 --- /dev/null +++ b/RMuseum/Models/PDFLibrary/OCRQueue.cs @@ -0,0 +1,18 @@ +namespace RMuseum.Models.PDFLibrary +{ + /// + /// OCR Queued Item + /// + public class OCRQueue + { + /// + /// id + /// + public int Id { get; set; } + + /// + /// PDF Book Id + /// + public int PDFBookId { get; set; } + } +} diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index 50fe56d6..1e8fdc89 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -3703,6 +3703,11 @@ PDF Ganjoor Links + + + OCR Queue Items + + @@ -12504,6 +12509,21 @@ pdf books + + + OCR Queued Item + + + + + id + + + + + PDF Book Id + + PDF Book @@ -18707,7 +18727,7 @@ - get next un-ocred PDF Book + get next un-ocred PDF Book and add it to a queue @@ -19609,7 +19629,14 @@ - + + + get pdf book by id + + + + + get all pdfbooks (including CoverImage info but not pages or tagibutes info) diff --git a/RMuseum/Services/IPDFLibraryService.cs b/RMuseum/Services/IPDFLibraryService.cs index 092c910d..9dad6691 100644 --- a/RMuseum/Services/IPDFLibraryService.cs +++ b/RMuseum/Services/IPDFLibraryService.cs @@ -20,7 +20,7 @@ namespace RMuseum.Services /// /// Task> StartImportingKnownSourceAsync(string srcUrl); - /// /// get pdf book by id /// /// diff --git a/RMuseum/Services/Implementation/PDFLibraryService.cs b/RMuseum/Services/Implementation/PDFLibraryService.cs index 02ad0142..18b78268 100644 --- a/RMuseum/Services/Implementation/PDFLibraryService.cs +++ b/RMuseum/Services/Implementation/PDFLibraryService.cs @@ -1568,19 +1568,32 @@ namespace RMuseum.Services.Implementation } /// - /// get next un-ocred PDF Book + /// get next un-ocred PDF Book and add it to a queue /// /// public async Task> GetNextUnOCRedPDFBookAsync() { try { + var maxOCRQueuedItemId = + await _context.OCRQueuedItems.AnyAsync() ? + await _context.OCRQueuedItems.AsNoTracking().MaxAsync(q => q.PDFBookId) + : 0; var pdfBook = await _context.PDFBooks.AsNoTracking() .Include(b => b.PDFFile) .Include(b => b.Pages) - .Where(b => b.Status == PublishStatus.Published && b.OCRed == false) + .Where(b => b.Status == PublishStatus.Published && b.OCRed == false && b.Id > maxOCRQueuedItemId) .OrderBy(b => b.Id) .FirstOrDefaultAsync(); + if (pdfBook != null) + { + _context.OCRQueuedItems.Add + (new OCRQueue() + { + PDFBookId = pdfBook.Id + }); + await _context.SaveChangesAsync(); + } return new RServiceResult(pdfBook); }