docs: #317 changing some poem centric methods to become section centric

This commit is contained in:
Hamid Reza Mohammadi 2022-05-05 19:58:38 +04:30
parent 8313cbb8f1
commit 47824c40cf
5 changed files with 20 additions and 20 deletions

View File

@ -2214,7 +2214,7 @@ namespace RMuseum.Controllers
public async Task<IActionResult> FindPoemRhyme(int id)
{
var res = await _ganjoorService.FindPoemRhyme(id);
var res = await _ganjoorService.FindPoemMainSectionRhyme(id);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);
@ -2235,7 +2235,7 @@ namespace RMuseum.Controllers
public async Task<IActionResult> FindPoemRhythm(int id)
{
var res = await _ganjoorService.FindPoemRhythm(id);
var res = await _ganjoorService.FindPoemMainSectionRhythm(id);
if (!string.IsNullOrEmpty(res.ExceptionString))
return BadRequest(res.ExceptionString);

View File

@ -11708,7 +11708,7 @@
<param name="userId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.FindPoemRhyme(System.Int32)">
<member name="M:RMuseum.Services.IGanjoorService.FindPoemMainSectionRhyme(System.Int32)">
<summary>
find poem rhyme
</summary>
@ -11731,7 +11731,7 @@
<param name="poemsNum"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.FindPoemRhythm(System.Int32)">
<member name="M:RMuseum.Services.IGanjoorService.FindPoemMainSectionRhythm(System.Int32)">
<summary>
find poem rhythm
</summary>
@ -14322,7 +14322,7 @@
<param name="userId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.FindPoemRhyme(System.Int32)">
<member name="M:RMuseum.Services.Implementation.GanjoorService.FindPoemMainSectionRhyme(System.Int32)">
<summary>
find poem rhyme
</summary>
@ -14345,7 +14345,7 @@
<param name="retag"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.FindPoemRhythm(System.Int32)">
<member name="M:RMuseum.Services.Implementation.GanjoorService.FindPoemMainSectionRhythm(System.Int32)">
<summary>
find poem rhythm
</summary>

View File

@ -620,7 +620,7 @@ namespace RMuseum.Services
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<RServiceResult<GanjooRhymeAnalysisResult>> FindPoemRhyme(int id);
Task<RServiceResult<GanjooRhymeAnalysisResult>> FindPoemMainSectionRhyme(int id);
/// <summary>
/// find category poem rhymes
@ -643,7 +643,7 @@ namespace RMuseum.Services
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<RServiceResult<string>> FindPoemRhythm(int id);
Task<RServiceResult<string>> FindPoemMainSectionRhythm(int id);
/// <summary>
/// find category poem rhymes

View File

@ -57,7 +57,7 @@ namespace RMuseum.Services.Implementation
for (int i = 0; i < poemIds.Length; i++)
{
var id = poemIds[i];
var res = await _FindPoemRhythm(id, context, httpClient, metres, true);
var res = await _FindPoemMainSectionRhythm(id, context, httpClient, metres, true);
if (res.Result == null)
res.Result = "";

View File

@ -3032,21 +3032,19 @@ namespace RMuseum.Services.Implementation
return new RServiceResult<string[]>(poems.Select(p => p.Title).ToArray());
}
private async Task<RServiceResult<GanjooRhymeAnalysisResult>> _FindPoemRhyme(int id, RMuseumDbContext context)
{
return new RServiceResult<GanjooRhymeAnalysisResult>(
LanguageUtils.FindRhyme(await context.GanjoorVerses.Where(v => v.PoemId == id).OrderBy(v => v.VOrder).ToListAsync())
);
}
/// <summary>
/// find poem rhyme
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjooRhymeAnalysisResult>> FindPoemRhyme(int id)
public async Task<RServiceResult<GanjooRhymeAnalysisResult>> FindPoemMainSectionRhyme(int id)
{
return await _FindPoemRhyme(id, _context);
var section = await _context.GanjoorPoemSections.AsNoTracking().Where(s => s.PoemId == id && s.SectionType == PoemSectionType.WholePoem && s.VerseType == VersePoemSectionType.First).OrderBy(s => s.Index).FirstOrDefaultAsync();
if (section == null)
return new RServiceResult<GanjooRhymeAnalysisResult>(null, "no sections");
var verses = await _context.GanjoorVerses.AsNoTracking().Where(v => v.PoemId == id).OrderBy(v => v.VOrder).ToListAsync();
return new RServiceResult<GanjooRhymeAnalysisResult>(LanguageUtils.FindRhyme(FilterSectionVerses(section, verses)));
}
private async Task _FindCategoryPoemsRhymesInternal(int catId, bool retag)
@ -3144,15 +3142,17 @@ namespace RMuseum.Services.Implementation
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<RServiceResult<string>> FindPoemRhythm(int id)
public async Task<RServiceResult<string>> FindPoemMainSectionRhythm(int id)
{
var metres = (await GetGanjoorMetres()).Result.Select(m => m.Rhythm).ToArray();
return await _FindPoemRhythm(id, _context, _httpClient, metres);
return await _FindPoemMainSectionRhythm(id, _context, _httpClient, metres);
}
private async Task<RServiceResult<string>> _FindPoemRhythm(int id, RMuseumDbContext context, HttpClient httpClient, string[] metres, bool alwaysReturnaAResult = false)
private async Task<RServiceResult<string>> _FindPoemMainSectionRhythm(int id, RMuseumDbContext context, HttpClient httpClient, string[] metres, bool alwaysReturnaAResult = false)
{
var section = await context.GanjoorPoemSections.AsNoTracking().Where(s => s.PoemId == id && s.SectionType == PoemSectionType.WholePoem && s.VerseType == VersePoemSectionType.First).OrderBy(s => s.Index).FirstOrDefaultAsync();
if (section == null)
return new RServiceResult<string>(null, "no main sections");
return await _FindSectionRhythm(section, context, httpClient, metres, alwaysReturnaAResult);
}
private async Task<RServiceResult<string>> _FindSectionRhythm(GanjoorPoemSection section, RMuseumDbContext context, HttpClient httpClient, string[] metres, bool alwaysReturnaAResult = false)