#407 adding OCRQueuedItems

This commit is contained in:
Hamid Reza Mohammadi 2023-08-08 19:13:08 +03:30
parent 71875f77a4
commit abc6b85efc
5 changed files with 68 additions and 5 deletions

View File

@ -548,5 +548,10 @@ namespace RMuseum.DbContext
/// </summary>
public DbSet<PDFGanjoorLink> PDFGanjoorLinks { get; set; }
/// <summary>
/// OCR Queue Items
/// </summary>
public DbSet<OCRQueue> OCRQueuedItems { get; set; }
}
}

View File

@ -0,0 +1,18 @@
namespace RMuseum.Models.PDFLibrary
{
/// <summary>
/// OCR Queued Item
/// </summary>
public class OCRQueue
{
/// <summary>
/// id
/// </summary>
public int Id { get; set; }
/// <summary>
/// PDF Book Id
/// </summary>
public int PDFBookId { get; set; }
}
}

View File

@ -3703,6 +3703,11 @@
PDF Ganjoor Links
</summary>
</member>
<member name="P:RMuseum.DbContext.RMuseumDbContext.OCRQueuedItems">
<summary>
OCR Queue Items
</summary>
</member>
<member name="T:RMuseum.Migrations.PictureFileExtUrl">
<inheritdoc />
</member>
@ -12504,6 +12509,21 @@
pdf books
</summary>
</member>
<member name="T:RMuseum.Models.PDFLibrary.OCRQueue">
<summary>
OCR Queued Item
</summary>
</member>
<member name="P:RMuseum.Models.PDFLibrary.OCRQueue.Id">
<summary>
id
</summary>
</member>
<member name="P:RMuseum.Models.PDFLibrary.OCRQueue.PDFBookId">
<summary>
PDF Book Id
</summary>
</member>
<member name="T:RMuseum.Models.PDFLibrary.PDFBook">
<summary>
PDF Book
@ -18707,7 +18727,7 @@
</member>
<member name="M:RMuseum.Services.Implementation.PDFLibraryService.GetNextUnOCRedPDFBookAsync">
<summary>
get next un-ocred PDF Book
get next un-ocred PDF Book and add it to a queue
</summary>
<returns></returns>
</member>
@ -19609,7 +19629,14 @@
<param name="srcUrl"></param>
<returns></returns>
</member>
<!-- Badly formed XML comment ignored for member "M:RMuseum.Services.IPDFLibraryService.GetPDFBookByIdAsync(System.Int32,RMuseum.Models.Artifact.PublishStatus[])" -->
<member name="M:RMuseum.Services.IPDFLibraryService.GetPDFBookByIdAsync(System.Int32,RMuseum.Models.Artifact.PublishStatus[])">
<summary>
get pdf book by id
</summary>
<param name="id"></param>
<param name="statusArray"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IPDFLibraryService.GetAllPDFBooksAsync(RSecurityBackend.Models.Generic.PagingParameterModel,RMuseum.Models.Artifact.PublishStatus[])">
<summary>
get all pdfbooks (including CoverImage info but not pages or tagibutes info)

View File

@ -20,7 +20,7 @@ namespace RMuseum.Services
/// <param name="srcUrl"></param>
/// <returns></returns>
Task<RServiceResult<bool>> StartImportingKnownSourceAsync(string srcUrl);
/// <summary
/// <summary>
/// get pdf book by id
/// </summary>
/// <param name="id"></param>

View File

@ -1568,19 +1568,32 @@ namespace RMuseum.Services.Implementation
}
/// <summary>
/// get next un-ocred PDF Book
/// get next un-ocred PDF Book and add it to a queue
/// </summary>
/// <returns></returns>
public async Task<RServiceResult<PDFBook>> 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>(pdfBook);
}