Skip to content

Commit

Permalink
comparison of usage stats of a selected word among all poets #471
Browse files Browse the repository at this point in the history
  • Loading branch information
hrmoh committed Mar 9, 2025
1 parent 4755601 commit 7d7bcc1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
18 changes: 18 additions & 0 deletions RMuseum/RMuseum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions RMuseum/Services/IGanjoorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,15 @@ Task<RServiceResult<GanjoorPoemSectionCorrectionViewModel>> ModeratePoemSectionC
/// <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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,35 @@ orderby cwd.Count descending
}
}

/// <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
Expand Down
2 changes: 1 addition & 1 deletion RMuseum/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void ConfigureServices(IServiceCollection services)
builder => builder.SetIsOriginAllowed(_ => true)
.AllowAnyMethod()
.AllowAnyHeader()
.WithExposedHeaders("paging-headers", "audio-upload-enabled")
.WithExposedHeaders("paging-headers", "audio-upload-enabled", "items-count")
.AllowCredentials()
);
});
Expand Down

0 comments on commit 7d7bcc1

Please sign in to comment.