diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs index e43ed9e8..b8a3d485 100644 --- a/RMuseum/Controllers/GanjoorController.cs +++ b/RMuseum/Controllers/GanjoorController.cs @@ -2147,6 +2147,24 @@ namespace RMuseum.Controllers return Ok(res.Result.Bookmarks); } + /// + /// start generating related poems info + /// + /// + [HttpPost] + [Route("generaterelatedpoemsinfo")] + [Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ImportOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(bool))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public IActionResult StartGeneratingRelatedPoemsInfo() + { + RServiceResult res = + _ganjoorService.StartGeneratingRelatedPoemsInfo(); + if (res.Result) + return Ok(); + return BadRequest(res.ExceptionString); + } + /// /// readonly mode /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index c2521657..b677988a 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -1287,6 +1287,12 @@ + + + start generating related poems info + + + readonly mode @@ -9453,6 +9459,12 @@ + + + start generating related poems info + + + translation service implementation @@ -10781,6 +10793,12 @@ + + + start generating related poems info + + + build sitemap diff --git a/RMuseum/Services/IGanjoorService.cs b/RMuseum/Services/IGanjoorService.cs index d94121ab..4328e692 100644 --- a/RMuseum/Services/IGanjoorService.cs +++ b/RMuseum/Services/IGanjoorService.cs @@ -652,5 +652,11 @@ namespace RMuseum.Services /// /// Task> GetCenturiesAsync(); + + /// + /// start generating related poems info + /// + /// + RServiceResult StartGeneratingRelatedPoemsInfo(); } } diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-RelatedPoems.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-RelatedPoems.cs index 24580da3..ce9a14ec 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-RelatedPoems.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-RelatedPoems.cs @@ -60,15 +60,18 @@ namespace RMuseum.Services.Implementation }; ganjoorCachedRelatedPoems.Add(newRelatedPoem); + + prePoetId = relatedPoem.Cat.PoetId; } else { ganjoorCachedRelatedPoems[ganjoorCachedRelatedPoems.Count - 1].PoetMorePoemsLikeThisCount++; } } - - context.GanjoorCachedRelatedPoems.AddRange(ganjoorCachedRelatedPoems); - + if(ganjoorCachedRelatedPoems.Count > 0) + { + context.GanjoorCachedRelatedPoems.AddRange(ganjoorCachedRelatedPoems); + } } /// @@ -103,6 +106,11 @@ namespace RMuseum.Services.Implementation return poemHtml; } + + /// + /// start generating related poems info + /// + /// public RServiceResult StartGeneratingRelatedPoemsInfo() { try @@ -121,7 +129,7 @@ namespace RMuseum.Services.Implementation await jobProgressServiceEF.UpdateJob(job.Id, 0, $"Query"); - var poemIds = await context.GanjoorPoems.AsNoTracking().Where(p => string.IsNullOrEmpty(p.RhymeLetters) && p.GanjoorMetreId != null).Select(p => p.Id).ToListAsync(); + var poemIds = await context.GanjoorPoems.AsNoTracking().Where(p => !string.IsNullOrEmpty(p.RhymeLetters) && p.GanjoorMetreId != null).Select(p => p.Id).ToListAsync(); await jobProgressServiceEF.UpdateJob(job.Id, 0, $"Updating Related Poems"); int percent = 0;