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

This commit is contained in:
Hamid Reza Mohammadi 2025-03-09 11:45:49 +03:30
parent 47556018c2
commit 7d7bcc130f
4 changed files with 57 additions and 1 deletions

View File

@ -17487,6 +17487,15 @@
<param name="poetId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetCategoryWordCountByTermAsync(System.String,System.Nullable{System.Int32},System.Nullable{System.Int32})">
<summary>
get CategoryWordCount for a specific term in a category
</summary>
<param name="term"></param>
<param name="catId"></param>
<param name="poetId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.TajikImportFromSqlite(System.Int32,System.String)">
<summary>
tajik import from sqlite
@ -19278,6 +19287,15 @@
<param name="poetId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCategoryWordCountByTermAsync(System.String,System.Nullable{System.Int32},System.Nullable{System.Int32})">
<summary>
get CategoryWordCount for a specific term in a category
</summary>
<param name="term"></param>
<param name="catId"></param>
<param name="poetId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.BuildCategoryWordCountsAsync(System.Boolean,System.Int32)">
<summary>
build word counts

View File

@ -1511,6 +1511,15 @@ namespace RMuseum.Services
/// <returns></returns>
Task<RServiceResult<(PaginationMetadata PagingMeta, PoetOrCatWordStat[] Items)>> GetCategoryWordCountsBySubCatsAsync(string term, PagingParameterModel paging, int? parentCatId, int? poetId);
/// <summary>
/// get CategoryWordCount for a specific term in a category
/// </summary>
/// <param name="term"></param>
/// <param name="catId"></param>
/// <param name="poetId"></param>
/// <returns></returns>
Task<RServiceResult<CategoryWordCount>> GetCategoryWordCountByTermAsync(string term, int? catId, int? poetId);
/// <summary>
/// tajik import from sqlite
/// </summary>

View File

@ -112,6 +112,35 @@ namespace RMuseum.Services.Implementation
}
}
/// <summary>
/// get CategoryWordCount for a specific term in a category
/// </summary>
/// <param name="term"></param>
/// <param name="catId"></param>
/// <param name="poetId"></param>
/// <returns></returns>
public async Task<RServiceResult<CategoryWordCount>> GetCategoryWordCountByTermAsync(string term, int? catId, int? poetId)
{
try
{
if (poetId != null && catId == null)
{
var cat = await _context.GanjoorCategories.AsNoTracking().Where(p => p.PoetId == poetId && p.ParentId == null).SingleAsync();
catId = cat.Id;
}
if (catId == null)
{
catId = 0;
}
return new RServiceResult<CategoryWordCount>(await _context.CategoryWordCounts.AsNoTracking().Where(s => s.CatId == catId && s.Word == term).OrderBy(s => s.RowNmbrInCat).FirstOrDefaultAsync());
}
catch (Exception exp)
{
return new RServiceResult<CategoryWordCount>(null, exp.ToString());
}
}
/// <summary>
/// build word counts

View File

@ -58,7 +58,7 @@ namespace RMuseum
builder => builder.SetIsOriginAllowed(_ => true)
.AllowAnyMethod()
.AllowAnyHeader()
.WithExposedHeaders("paging-headers", "audio-upload-enabled")
.WithExposedHeaders("paging-headers", "audio-upload-enabled", "items-count")
.AllowCredentials()
);
});