docs: #306 adding poem sections to GanjoorPoemCompleteViewModel

This commit is contained in:
Hamid Reza Mohammadi 2022-04-07 10:41:02 +04:30
parent 1415734b37
commit 7293fdd6d3
7 changed files with 131 additions and 69 deletions

View File

@ -1,39 +1,5 @@
namespace RMuseum.Models.Ganjoor
{
/// <summary>
/// poem section type
/// </summary>
public enum PoemSectionType
{
/// <summary>
/// sections like paragraphs or poems within paragraphs of text
/// </summary>
WholePoem = 0,
/// <summary>
/// bands of a multi-band poem
/// </summary>
Band = 1,
/// <summary>
/// band couplets (virtual) some are virtual because they contain verse from different parts of poems (like verses from all band couplets)
/// </summary>
BandCouplets = 2,
/// <summary>
/// couplets (virtual) for Masnavi
/// </summary>
Couplet = 3,
}
/// <summary>
/// how GanjoorPoemSection is linked to GanjoorVerse
/// </summary>
public enum VersePoemSectionType
{
First = 1,
Second = 2,
Third = 3,
}
/// <summary>
/// Ganjoor Poem Section
/// </summary>

View File

@ -0,0 +1,25 @@
namespace RMuseum.Models.Ganjoor
{
/// <summary>
/// poem section type
/// </summary>
public enum PoemSectionType
{
/// <summary>
/// sections like paragraphs or poems within paragraphs of text
/// </summary>
WholePoem = 0,
/// <summary>
/// bands of a multi-band poem
/// </summary>
Band = 1,
/// <summary>
/// band couplets (virtual) some are virtual because they contain verse from different parts of poems (like verses from all band couplets)
/// </summary>
BandCouplets = 2,
/// <summary>
/// couplets (virtual) for Masnavi
/// </summary>
Couplet = 3,
}
}

View File

@ -0,0 +1,12 @@
namespace RMuseum.Models.Ganjoor
{
/// <summary>
/// how GanjoorPoemSection is linked to GanjoorVerse
/// </summary>
public enum VersePoemSectionType
{
First = 1,
Second = 2,
Third = 3,
}
}

View File

@ -131,5 +131,10 @@ namespace RMuseum.Models.Ganjoor.ViewModels
/// top 6 related poems
/// </summary>
public GanjoorCachedRelatedPoem[] Top6RelatedPoems { get; set; }
/// <summary>
/// poem sections
/// </summary>
public GanjoorPoemSection[] Sections { get; set; }
}
}

View File

@ -6746,36 +6746,6 @@
metre
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.PoemSectionType">
<summary>
poem section type
</summary>
</member>
<member name="F:RMuseum.Models.Ganjoor.PoemSectionType.WholePoem">
<summary>
sections like paragraphs or poems within paragraphs of text
</summary>
</member>
<member name="F:RMuseum.Models.Ganjoor.PoemSectionType.Band">
<summary>
bands of a multi-band poem
</summary>
</member>
<member name="F:RMuseum.Models.Ganjoor.PoemSectionType.BandCouplets">
<summary>
band couplets (virtual) some are virtual because they contain verse from different parts of poems (like verses from all band couplets)
</summary>
</member>
<member name="F:RMuseum.Models.Ganjoor.PoemSectionType.Couplet">
<summary>
couplets (virtual) for Masnavi
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.VersePoemSectionType">
<summary>
how GanjoorPoemSection is linked to GanjoorVerse
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.GanjoorPoemSection">
<summary>
Ganjoor Poem Section
@ -7554,6 +7524,36 @@
https://open.spotify.com/
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.PoemSectionType">
<summary>
poem section type
</summary>
</member>
<member name="F:RMuseum.Models.Ganjoor.PoemSectionType.WholePoem">
<summary>
sections like paragraphs or poems within paragraphs of text
</summary>
</member>
<member name="F:RMuseum.Models.Ganjoor.PoemSectionType.Band">
<summary>
bands of a multi-band poem
</summary>
</member>
<member name="F:RMuseum.Models.Ganjoor.PoemSectionType.BandCouplets">
<summary>
band couplets (virtual) some are virtual because they contain verse from different parts of poems (like verses from all band couplets)
</summary>
</member>
<member name="F:RMuseum.Models.Ganjoor.PoemSectionType.Couplet">
<summary>
couplets (virtual) for Masnavi
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.VersePoemSectionType">
<summary>
how GanjoorPoemSection is linked to GanjoorVerse
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.VersePosition">
<summary>
معنی فیلد position در جدول verse با توجه به مقادیر این ساختار داده مشخص می شود.
@ -8376,6 +8376,11 @@
top 6 related poems
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCompleteViewModel.Sections">
<summary>
poem sections
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel">
<summary>
poem correction view model
@ -10833,7 +10838,7 @@
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
<member name="M:RMuseum.Services.IGanjoorService.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
<summary>
Get Poem By Id
</summary>
@ -10848,6 +10853,7 @@
<param name="verseDetails"></param>
<param name="navigation"></param>
<param name="relatedpoems"></param>
<param name="sections"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetPoemByUrl(System.String,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
@ -10873,6 +10879,13 @@
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetPoemSections(System.Int32)">
<summary>
get poem sections
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetUserPoemRecitationsUpVotes(System.Int32,System.Guid)">
<summary>
get user up votes for the recitations of a poem
@ -13542,6 +13555,13 @@
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemSections(System.Int32)">
<summary>
get poem sections
</summary>
<param name="id"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetUserPoemRecitationsUpVotes(System.Int32,System.Guid)">
<summary>
get user up votes for the recitations of a poem
@ -13674,7 +13694,7 @@
<param name="navigation"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemById(System.Int32,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
<summary>
Get Poem By Id
</summary>
@ -13689,6 +13709,7 @@
<param name="verseDetails"></param>
<param name="navigation"></param>
<param name="relatedpoems"></param>
<param name="sections">sections</param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.DeletePoemCorrections(System.Guid,System.Int32)">

View File

@ -110,8 +110,9 @@ namespace RMuseum.Services
/// <param name="verseDetails"></param>
/// <param name="navigation"></param>
/// <param name="relatedpoems"></param>
/// <param name="sections"></param>
/// <returns></returns>
Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemById(int id, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true, bool relatedpoems = true);
Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemById(int id, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true, bool relatedpoems = true, bool sections = true);
/// <summary>
/// Get Poem By Url
@ -136,6 +137,13 @@ namespace RMuseum.Services
/// <returns></returns>
Task<RServiceResult<PublicRecitationViewModel[]>> GetPoemRecitations(int id);
/// <summary>
/// get poem sections
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<RServiceResult<GanjoorPoemSection[]>> GetPoemSections(int id);
/// <summary>
/// get user up votes for the recitations of a poem
/// </summary>

View File

@ -633,6 +633,20 @@ namespace RMuseum.Services.Implementation
return new RServiceResult<PublicRecitationViewModel[]>(recitations);
}
/// <summary>
/// get poem sections
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPoemSection[]>> GetPoemSections(int id)
{
return new RServiceResult<GanjoorPoemSection[]>(
await _context.GanjoorPoemSections.AsNoTracking().Where(s => s.PoemId == id).ToArrayAsync()
);
}
/// <summary>
/// get user up votes for the recitations of a poem
/// </summary>
@ -1452,8 +1466,9 @@ namespace RMuseum.Services.Implementation
/// <param name="verseDetails"></param>
/// <param name="navigation"></param>
/// <param name="relatedpoems"></param>
/// <param name="sections">sections</param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemById(int id, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true, bool relatedpoems = true)
public async Task<RServiceResult<GanjoorPoemCompleteViewModel>> GetPoemById(int id, bool catInfo = true, bool catPoems = false, bool rhymes = true, bool recitations = true, bool images = true, bool songs = true, bool comments = true, bool verseDetails = true, bool navigation = true, bool relatedpoems = true, bool sections = true)
{
var cachKey = $"GetPoemById({id}, {catInfo}, {catPoems}, {rhymes}, {recitations}, {images}, {songs}, {comments}, {verseDetails}, {navigation})";
if (!_memoryCache.TryGetValue(cachKey, out GanjoorPoemCompleteViewModel poemViewModel))
@ -1600,6 +1615,15 @@ namespace RMuseum.Services.Implementation
top6relatedPoems = relatedPoemsRes.Result;
}
GanjoorPoemSection[] poemSections = null;
if(sections)
{
var poemSectionsRes = await GetPoemSections(id);
if (!string.IsNullOrEmpty(poemSectionsRes.ExceptionString))
return new RServiceResult<GanjoorPoemCompleteViewModel>(null, poemSectionsRes.ExceptionString);
poemSections = poemSectionsRes.Result;
}
poemViewModel = new GanjoorPoemCompleteViewModel()
{
@ -1627,7 +1651,8 @@ namespace RMuseum.Services.Implementation
Verses = verses,
Songs = tracks,
Comments = poemComments,
Top6RelatedPoems = top6relatedPoems
Top6RelatedPoems = top6relatedPoems,
Sections = poemSections
};
if (AggressiveCacheEnabled)