#444 recount a poet words
This commit is contained in:
parent
99ac06b3b9
commit
d405291f28
@ -327,7 +327,7 @@
|
||||
|
||||
<p><a role="button" onclick="rebuildDigitalSourcesStats()" class="actionlink" title="بازسازی آمار منابع دیجیتال">بازسازی آمار منابع دیجیتال</a></p>
|
||||
|
||||
<p><a role="button" onclick="rebuildRebuildWordCounts()" class="actionlink" title="ادامه شمارش کلمات">ادامه شمارش کلمات</a></p>
|
||||
<p><a role="button" onclick="rebuildRebuildWordCounts(@Model.PageInformation.PoetOrCat.Poet.Id)" class="actionlink" title="شمارش واژگان">شمارش واژگان</a></p>
|
||||
|
||||
|
||||
<table>
|
||||
|
||||
@ -373,13 +373,13 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
return new OkObjectResult(false);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostRebuildWordCountsAsync()
|
||||
public async Task<IActionResult> OnPostRebuildWordCountsAsync(int poetId)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/wordcounts/rebuild", null);
|
||||
HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/wordcounts/rebuild/{poetId}", null);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return BadRequest(JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync()));
|
||||
|
||||
@ -199,11 +199,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
function rebuildRebuildWordCounts() {
|
||||
if (!confirm('آیا از ادامه شمارش کلمات اطمینان دارید؟'))
|
||||
function rebuildRebuildWordCounts(poetId) {
|
||||
if (!confirm('آیا از شمارش واژگان برای شاعر جاری با کد '+poetId.toString() + ' اطمینان دارید؟'))
|
||||
return;
|
||||
|
||||
var url = '?handler=RebuildWordCounts';
|
||||
var url = '?handler=RebuildWordCounts?poetId=' + poetId.toString();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
||||
@ -4188,15 +4188,17 @@ namespace RMuseum.Controllers
|
||||
/// <summary>
|
||||
/// build word counts
|
||||
/// </summary>
|
||||
/// <param name="reset"></param>
|
||||
/// <param name="poetId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpPost("wordcounts/rebuild")]
|
||||
[HttpPost("wordcounts/rebuild/{poetId}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> BuildCategoryWordCountsAsync(bool reset = false)
|
||||
public async Task<IActionResult> BuildCategoryWordCountsAsync(bool reset = false, int poetId = 0)
|
||||
{
|
||||
await _ganjoorService.BuildCategoryWordCountsAsync(reset);
|
||||
await _ganjoorService.BuildCategoryWordCountsAsync(reset, poetId);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
@ -2208,10 +2208,12 @@
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.BuildCategoryWordCountsAsync(System.Boolean)">
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.BuildCategoryWordCountsAsync(System.Boolean,System.Int32)">
|
||||
<summary>
|
||||
build word counts
|
||||
</summary>
|
||||
<param name="reset"></param>
|
||||
<param name="poetId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.FillCategoryWordCountsRowNmbrInCat">
|
||||
@ -16614,10 +16616,12 @@
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.BuildCategoryWordCountsAsync(System.Boolean)">
|
||||
<member name="M:RMuseum.Services.IGanjoorService.BuildCategoryWordCountsAsync(System.Boolean,System.Int32)">
|
||||
<summary>
|
||||
build word counts
|
||||
</summary>
|
||||
<param name="reset"></param>
|
||||
<param name="poetId"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.FillCategoryWordCountsRowNmbrInCat">
|
||||
<summary>
|
||||
@ -18215,10 +18219,12 @@
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.BuildCategoryWordCountsAsync(System.Boolean)">
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.BuildCategoryWordCountsAsync(System.Boolean,System.Int32)">
|
||||
<summary>
|
||||
build word counts
|
||||
</summary>
|
||||
<param name="reset"></param>
|
||||
<param name="poetId"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.FillCategoryWordCountsRowNmbrInCat">
|
||||
<summary>
|
||||
|
||||
@ -1436,7 +1436,9 @@ namespace RMuseum.Services
|
||||
/// <summary>
|
||||
/// build word counts
|
||||
/// </summary>
|
||||
Task BuildCategoryWordCountsAsync(bool reset);
|
||||
/// <param name="reset"></param>
|
||||
/// <param name="poetId"></param>
|
||||
Task BuildCategoryWordCountsAsync(bool reset, int poetId);
|
||||
|
||||
/// <summary>
|
||||
/// fill CategoryWordCounts.RowNmbrInCat
|
||||
|
||||
@ -70,7 +70,9 @@ namespace RMuseum.Services.Implementation
|
||||
/// <summary>
|
||||
/// build word counts
|
||||
/// </summary>
|
||||
public async Task BuildCategoryWordCountsAsync(bool reset)
|
||||
/// <param name="reset"></param>
|
||||
/// <param name="poetId"></param>
|
||||
public async Task BuildCategoryWordCountsAsync(bool reset, int poetId)
|
||||
{
|
||||
int lastFinishedPoetId = 0;
|
||||
if (!reset)
|
||||
@ -91,7 +93,8 @@ namespace RMuseum.Services.Implementation
|
||||
var job = (await jobProgressServiceEF.NewJob($"BuildCategoryWordCounts", "Query data")).Result;
|
||||
try
|
||||
{
|
||||
var poets = await context.GanjoorPoets.AsNoTracking().Where(p => p.Published && p.Id > lastFinishedPoetId).OrderBy(p => p.Id).ToListAsync();
|
||||
var poets = poetId == 0 ? await context.GanjoorPoets.AsNoTracking().Where(p => p.Published && p.Id > lastFinishedPoetId).OrderBy(p => p.Id).ToListAsync()
|
||||
: await context.GanjoorPoets.AsNoTracking().Where(p => p.Published && p.Id == poetId).OrderBy(p => p.Id).ToListAsync();
|
||||
foreach (var poet in poets)
|
||||
{
|
||||
var poetCat = await context.GanjoorCategories.AsNoTracking().Where(c => c.PoetId == poet.Id && c.ParentId == null).SingleAsync();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user