#268 improvements on missing rhthms finder API

This commit is contained in:
Hamid Reza Mohammadi 2021-12-30 08:57:38 +03:30
parent 1f55ab69f5
commit 691a031fa7
4 changed files with 22 additions and 8 deletions

View File

@ -529,17 +529,18 @@ namespace RMuseum.Controllers
/// Start Finding Missing Rhythms
/// </summary>
/// <param name="onlyPoemsWithRhymes"></param>
/// <param name="poemsNum"></param>
/// <returns></returns>
[HttpPost]
[Route("startfindingmissingrhythms")]
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public IActionResult StartFindingMissingRhythms(bool onlyPoemsWithRhymes)
public IActionResult StartFindingMissingRhythms(bool onlyPoemsWithRhymes = true, int poemsNum = 1000)
{
RServiceResult<bool> res =
_ganjoorService.StartFindingMissingRhythms(onlyPoemsWithRhymes);
_ganjoorService.StartFindingMissingRhythms(onlyPoemsWithRhymes, poemsNum);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
return Ok(res.Result);

View File

@ -850,11 +850,12 @@
<param name="rhythm"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.StartFindingMissingRhythms(System.Boolean)">
<member name="M:RMuseum.Controllers.GanjoorController.StartFindingMissingRhythms(System.Boolean,System.Int32)">
<summary>
Start Finding Missing Rhythms
</summary>
<param name="onlyPoemsWithRhymes"></param>
<param name="poemsNum"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GenerateTableOfContents(System.Int32,RMuseum.Models.Ganjoor.GanjoorTOC)">
@ -9929,11 +9930,12 @@
<param name="retag"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.StartFindingMissingRhythms(System.Boolean)">
<member name="M:RMuseum.Services.IGanjoorService.StartFindingMissingRhythms(System.Boolean,System.Int32)">
<summary>
Start finding missing rhthms
</summary>
<param name="onlyPoemsWithRhymes"></param>
<param name="poemsNum"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.FindPoemRhythm(System.Int32)">
@ -11347,11 +11349,12 @@
<param name="rhythm"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.StartFindingMissingRhythms(System.Boolean)">
<member name="M:RMuseum.Services.Implementation.GanjoorService.StartFindingMissingRhythms(System.Boolean,System.Int32)">
<summary>
Start finding missing rhthms
</summary>
<param name="onlyPoemsWithRhymes"></param>
<param name="poemsNum"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.StartGeneratingSubCatsTOC(System.Guid,System.Int32)">

View File

@ -561,8 +561,9 @@ namespace RMuseum.Services
/// Start finding missing rhthms
/// </summary>
/// <param name="onlyPoemsWithRhymes"></param>
/// <param name="poemsNum"></param>
/// <returns></returns>
RServiceResult<bool> StartFindingMissingRhythms(bool onlyPoemsWithRhymes);
RServiceResult<bool> StartFindingMissingRhythms(bool onlyPoemsWithRhymes, int poemsNum = 1000);
/// <summary>
/// find poem rhythm

View File

@ -100,8 +100,9 @@ namespace RMuseum.Services.Implementation
/// Start finding missing rhthms
/// </summary>
/// <param name="onlyPoemsWithRhymes"></param>
/// <param name="poemsNum"></param>
/// <returns></returns>
public RServiceResult<bool> StartFindingMissingRhythms(bool onlyPoemsWithRhymes)
public RServiceResult<bool> StartFindingMissingRhythms(bool onlyPoemsWithRhymes, int poemsNum = 1000)
{
_backgroundTaskQueue.QueueBackgroundWorkItem
(
@ -113,7 +114,15 @@ namespace RMuseum.Services.Implementation
var job = (await jobProgressServiceEF.NewJob($"StartFindingMissingRhythms", "Query data")).Result;
try
{
var poemIds = await context.GanjoorPoems.AsNoTracking().Where(p => p.GanjoorMetreId == null && (onlyPoemsWithRhymes == false || !string.IsNullOrEmpty(p.RhymeLetters))).Select(p => p.Id).ToArrayAsync();
var poemIds = await context.GanjoorPoems.AsNoTracking()
.Where(p =>
p.GanjoorMetreId == null && (onlyPoemsWithRhymes == false || !string.IsNullOrEmpty(p.RhymeLetters))
&&
false == (context.GanjoorVerses.Where(v => v.PoemId == p.Id && (v.VersePosition == VersePosition.Paragraph || v.VersePosition == VersePosition.Single)).Any() )
)
.Take(poemsNum)
.Select(p => p.Id)
.ToArrayAsync();
await jobProgressServiceEF.UpdateJob(job.Id, 0, $"Total: {poemIds.Length}");
var metres = (await GetGanjoorMetres()).Result.Select(m => m.Rhythm).ToArray();