comparison of usage stats of a selected word among all poets #471

This commit is contained in:
Hamid Reza Mohammadi 2025-03-07 21:08:55 +03:30
parent 62d3b1a7a9
commit 650b12eb54
6 changed files with 23 additions and 15 deletions

View File

@ -23,7 +23,7 @@
{
<tr class="e">
<td class="c1">@((i + 1).ToPersianNumbers())</td>
<td class="c2"><a href="/search?s=@Model.Term&author=@Model.WordStats[i].Id">@Model.WordStats[i].Name</a></td>
<td class="c2"><a href="/search?s=@Model.Term&author=@Model.WordStats[i].PoetId">@Model.WordStats[i].Name</a></td>
<td class="c3">@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.WordStats[i].Count)</td>
@if (Model.WordStats[i].TotalWordCount == 0)
{
@ -40,7 +40,7 @@
{
<tr>
<td class="c1">@((i + 1).ToPersianNumbers())</td>
<td class="c2"><a href="/search?s=@Model.Term&author=@Model.WordStats[i].Id">@Model.WordStats[i].Name</a></td>
<td class="c2"><a href="/search?s=@Model.Term&author=@Model.WordStats[i].PoetId">@Model.WordStats[i].Name</a></td>
<td class="c3">@RMuseum.Services.Implementation.LanguageUtils.FormatMoney(Model.WordStats[i].Count)</td>
@if (Model.WordStats[i].TotalWordCount == 0)
{

View File

@ -4373,16 +4373,17 @@ namespace RMuseum.Controllers
/// </summary>
/// <param name="term"></param>
/// <param name="paging"></param>
/// <param name="parentCatId"></param>
/// <returns></returns>
[HttpGet]
[Route("wordcounts/bypoet")]
[Route("wordcounts/bycat")]
[AllowAnonymous]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<PoetOrCatWordStat>))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task<IActionResult> GetCategoryWordCountsByPoetsAsync(string term, [FromQuery] PagingParameterModel paging)
public async Task<IActionResult> GetCategoryWordCountsByPoetsAsync(string term, [FromQuery] PagingParameterModel paging, int? parentCatId)
{
var pagedResult = await _ganjoorService.GetCategoryWordCountsByPoetsAsync(term, paging);
var pagedResult = await _ganjoorService.GetCategoryWordCountsBySubCatsAsync(term, paging, parentCatId);
if (!string.IsNullOrEmpty(pagedResult.ExceptionString))
return BadRequest(pagedResult.ExceptionString);

View File

@ -2,7 +2,8 @@
{
public class PoetOrCatWordStat
{
public int Id { get; set; }
public int CatId { get; set; }
public int PoetId { get; set; }
public string Name { get; set; }
public int Count { get; set; }
public int RowNmbrInCat { get; set; }

View File

@ -2345,12 +2345,13 @@
<param name="catId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetCategoryWordCountsByPoetsAsync(System.String,RSecurityBackend.Models.Generic.PagingParameterModel)">
<member name="M:RMuseum.Controllers.GanjoorController.GetCategoryWordCountsByPoetsAsync(System.String,RSecurityBackend.Models.Generic.PagingParameterModel,System.Nullable{System.Int32})">
<summary>
comparison of word counts for poets
</summary>
<param name="term"></param>
<param name="paging"></param>
<param name="parentCatId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.GetTajikPoetsAsync">
@ -17467,12 +17468,13 @@
<param name="catId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetCategoryWordCountsByPoetsAsync(System.String,RSecurityBackend.Models.Generic.PagingParameterModel)">
<member name="M:RMuseum.Services.IGanjoorService.GetCategoryWordCountsBySubCatsAsync(System.String,RSecurityBackend.Models.Generic.PagingParameterModel,System.Nullable{System.Int32})">
<summary>
comparison of word counts for poets
</summary>
<param name="term"></param>
<param name="paging"></param>
<param name="parentCatId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.TajikImportFromSqlite(System.Int32,System.String)">
@ -19256,12 +19258,13 @@
<param name="catId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCategoryWordCountsByPoetsAsync(System.String,RSecurityBackend.Models.Generic.PagingParameterModel)">
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCategoryWordCountsBySubCatsAsync(System.String,RSecurityBackend.Models.Generic.PagingParameterModel,System.Nullable{System.Int32})">
<summary>
comparison of word counts for poets
comparison of word counts for poets ot subcats
</summary>
<param name="term"></param>
<param name="paging"></param>
<param name="parentCatId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.BuildCategoryWordCountsAsync(System.Boolean,System.Int32)">

View File

@ -1506,8 +1506,9 @@ namespace RMuseum.Services
/// </summary>
/// <param name="term"></param>
/// <param name="paging"></param>
/// <param name="parentCatId"></param>
/// <returns></returns>
Task<RServiceResult<(PaginationMetadata PagingMeta, PoetOrCatWordStat[] Items)>> GetCategoryWordCountsByPoetsAsync(string term, PagingParameterModel paging);
Task<RServiceResult<(PaginationMetadata PagingMeta, PoetOrCatWordStat[] Items)>> GetCategoryWordCountsBySubCatsAsync(string term, PagingParameterModel paging, int? parentCatId);
/// <summary>
/// tajik import from sqlite

View File

@ -68,12 +68,13 @@ namespace RMuseum.Services.Implementation
}
/// <summary>
/// comparison of word counts for poets
/// comparison of word counts for poets ot subcats
/// </summary>
/// <param name="term"></param>
/// <param name="paging"></param>
/// <param name="parentCatId"></param>
/// <returns></returns>
public async Task<RServiceResult<(PaginationMetadata PagingMeta, PoetOrCatWordStat[] Items)>> GetCategoryWordCountsByPoetsAsync(string term, PagingParameterModel paging)
public async Task<RServiceResult<(PaginationMetadata PagingMeta, PoetOrCatWordStat[] Items)>> GetCategoryWordCountsBySubCatsAsync(string term, PagingParameterModel paging, int? parentCatId)
{
try
{
@ -81,12 +82,13 @@ namespace RMuseum.Services.Implementation
from cwd in _context.CategoryWordCounts
join catsum in _context.CategoryWordCountSummaries on cwd.CatId equals catsum.CatId
join cat in _context.GanjoorCategories on cwd.CatId equals cat.Id
where cat.ParentId == null && cwd.Word == term
where cat.ParentId == parentCatId && cwd.Word == term
orderby cwd.Count descending
select
new PoetOrCatWordStat()
{
Id = cat.PoetId,
CatId = cat.Id,
PoetId = cat.PoetId,
Name = cat.Title,
Count = cwd.Count,
RowNmbrInCat = cwd.RowNmbrInCat,