docs: #306 adding metre 2 to 4 to the correction model

This commit is contained in:
Hamid Reza Mohammadi 2022-04-19 20:16:31 +04:30
parent 1132423430
commit 2cf87972a8
5 changed files with 275 additions and 19 deletions

View File

@ -113,6 +113,51 @@ namespace RMuseum.Models.Ganjoor
/// had any effect on poem after moderation? effective in history
/// </summary>
public bool AffectedThePoem { get; set; }
/// <summary>
/// rhythm 2
/// </summary>
public string Rhythm2 { get; set; }
/// <summary>
/// original rhythm 2
/// </summary>
public string OriginalRhythm2 { get; set; }
/// <summary>
/// review result for rhythm 2
/// </summary>
public CorrectionReviewResult Rhythm2Result { get; set; }
/// <summary>
/// rhythm 3
/// </summary>
public string Rhythm3 { get; set; }
/// <summary>
/// original rhythm 3
/// </summary>
public string OriginalRhythm3 { get; set; }
/// <summary>
/// review result for rhythm 3
/// </summary>
public CorrectionReviewResult Rhythm3Result { get; set; }
/// <summary>
/// rhythm 4
/// </summary>
public string Rhythm4 { get; set; }
/// <summary>
/// original rhythm 4
/// </summary>
public string OriginalRhythm4 { get; set; }
/// <summary>
/// review result for rhythm 4
/// </summary>
public CorrectionReviewResult Rhythm4Result { get; set; }
}

View File

@ -95,5 +95,17 @@ namespace RMuseum.Models.Ganjoor
/// </summary>
[NotMapped]
public GanjoorCachedRelatedSection[] Top6RelatedSections { get; set; }
/// <summary>
/// old metre id to see it needs refreshing related sections
/// </summary>
[NotMapped]
public int? OldGanjoorMetreId { get; set; }
/// <summary>
/// old rhyme letters to see it needs refreshing related sections
/// </summary>
[NotMapped]
public string OldRhymeLetters { get; set; }
}
}

View File

@ -86,5 +86,50 @@ namespace RMuseum.Models.Ganjoor.ViewModels
/// review result for rhythm
/// </summary>
public CorrectionReviewResult RhythmResult { get; set; }
/// <summary>
/// rhythm 2
/// </summary>
public string Rhythm2 { get; set; }
/// <summary>
/// original rhythm 2
/// </summary>
public string OriginalRhythm2 { get; set; }
/// <summary>
/// review result for rhythm 2
/// </summary>
public CorrectionReviewResult Rhythm2Result { get; set; }
/// <summary>
/// rhythm 3
/// </summary>
public string Rhythm3 { get; set; }
/// <summary>
/// original rhythm 3
/// </summary>
public string OriginalRhythm3 { get; set; }
/// <summary>
/// review result for rhythm 3
/// </summary>
public CorrectionReviewResult Rhythm3Result { get; set; }
/// <summary>
/// rhythm 4
/// </summary>
public string Rhythm4 { get; set; }
/// <summary>
/// original rhythm 4
/// </summary>
public string OriginalRhythm4 { get; set; }
/// <summary>
/// review result for rhythm 4
/// </summary>
public CorrectionReviewResult Rhythm4Result { get; set; }
}
}

View File

@ -6807,6 +6807,51 @@
had any effect on poem after moderation? effective in history
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemCorrection.Rhythm2">
<summary>
rhythm 2
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemCorrection.OriginalRhythm2">
<summary>
original rhythm 2
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemCorrection.Rhythm2Result">
<summary>
review result for rhythm 2
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemCorrection.Rhythm3">
<summary>
rhythm 3
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemCorrection.OriginalRhythm3">
<summary>
original rhythm 3
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemCorrection.Rhythm3Result">
<summary>
review result for rhythm 3
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemCorrection.Rhythm4">
<summary>
rhythm 4
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemCorrection.OriginalRhythm4">
<summary>
original rhythm 4
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemCorrection.Rhythm4Result">
<summary>
review result for rhythm 4
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.GanjoorPoemFormat">
<summary>
poem format
@ -7050,6 +7095,16 @@
top 6 related sections
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemSection.OldGanjoorMetreId">
<summary>
old metre id to see it needs refreshing related sections
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoemSection.OldRhymeLetters">
<summary>
old rhyme letters to see it needs refreshing related sections
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.GanjoorPoemTranslation">
<summary>
poem translation
@ -8717,6 +8772,51 @@
review result for rhythm
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel.Rhythm2">
<summary>
rhythm 2
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel.OriginalRhythm2">
<summary>
original rhythm 2
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel.Rhythm2Result">
<summary>
review result for rhythm 2
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel.Rhythm3">
<summary>
rhythm 3
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel.OriginalRhythm3">
<summary>
original rhythm 3
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel.Rhythm3Result">
<summary>
review result for rhythm 3
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel.Rhythm4">
<summary>
rhythm 4
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel.OriginalRhythm4">
<summary>
original rhythm 4
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemCorrectionViewModel.Rhythm4Result">
<summary>
review result for rhythm 4
</summary>
</member>
<member name="T:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemSummaryViewModel">
<summary>
poem summary

View File

@ -34,6 +34,7 @@ namespace RMuseum.Services.Implementation
dbCorrection.ApplicationOrder = await _context.GanjoorPoemCorrections.Where(c => c.Reviewed).AnyAsync() ? 1 + await _context.GanjoorPoemCorrections.Where(c => c.Reviewed).MaxAsync(c => c.ApplicationOrder) : 1;
dbCorrection.Reviewed = true;
dbCorrection.AffectedThePoem = false;
dbCorrection.ReviewNote = moderation.ReviewNote;
if (dbCorrection == null)
return new RServiceResult<GanjoorPoemCorrectionViewModel>(null);
@ -47,7 +48,7 @@ namespace RMuseum.Services.Implementation
if (moderation.Result == CorrectionReviewResult.NotReviewed)
return new RServiceResult<GanjoorPoemCorrectionViewModel>(null, "تغییرات عنوان بررسی نشده است.");
dbCorrection.Result = moderation.Result;
dbCorrection.ReviewNote = moderation.ReviewNote;
if (dbCorrection.Result == CorrectionReviewResult.Approved)
{
dbCorrection.AffectedThePoem = true;
@ -57,36 +58,89 @@ namespace RMuseum.Services.Implementation
}
var sections = await _context.GanjoorPoemSections.Where(s => s.PoemId == moderation.PoemId).OrderBy(s => s.SectionType).ThenBy(s => s.Index).ToListAsync();
bool metreChanged = false;
var mainSection = sections.First(s => s.SectionType == PoemSectionType.WholePoem && s.VerseType == VersePoemSectionType.First);
if (mainSection == null)
{
return new RServiceResult<GanjoorPoemCorrectionViewModel>(null, "شعر فاقد بخش اصلی برای ذخیرهٔ وزن است.");
}
if (dbCorrection.Rhythm != null)
{
if (moderation.RhythmResult == CorrectionReviewResult.NotReviewed)
return new RServiceResult<GanjoorPoemCorrectionViewModel>(null, "تغییرات وزن بررسی نشده است.");
dbCorrection.RhythmResult = moderation.RhythmResult;
dbCorrection.ReviewNote = moderation.ReviewNote;
if (dbCorrection.RhythmResult == CorrectionReviewResult.Approved)
{
dbCorrection.AffectedThePoem = true;
var mainSection = sections.First(s => s.SectionType == PoemSectionType.WholePoem && s.VerseType == VersePoemSectionType.First);
if (mainSection == null)
mainSection.OldGanjoorMetreId = mainSection.GanjoorMetreId;
if (moderation.Rhythm == "")
{
return new RServiceResult<GanjoorPoemCorrectionViewModel>(null, "شعر فاقد بخش اصلی برای ذخیرهٔ وزن است.");
mainSection.GanjoorMetreId = null;
}
var metre = await _context.GanjoorMetres.AsNoTracking().Where(m => m.Rhythm == moderation.Rhythm).SingleOrDefaultAsync();
if (metre == null)
else
{
metre = new GanjoorMetre()
var metre = await _context.GanjoorMetres.AsNoTracking().Where(m => m.Rhythm == moderation.Rhythm).SingleOrDefaultAsync();
if (metre == null)
{
Rhythm = moderation.Rhythm,
VerseCount = 0
};
_context.GanjoorMetres.Add(metre);
await _context.SaveChangesAsync();
metre = new GanjoorMetre()
{
Rhythm = moderation.Rhythm,
VerseCount = 0
};
_context.GanjoorMetres.Add(metre);
await _context.SaveChangesAsync();
}
mainSection.GanjoorMetreId = metre.Id;
}
}
}
if (dbCorrection.Rhythm2 != null)
{
if (moderation.Rhythm2Result == CorrectionReviewResult.NotReviewed)
return new RServiceResult<GanjoorPoemCorrectionViewModel>(null, "تغییرات وزن دوم بررسی نشده است.");
dbCorrection.Rhythm2Result = moderation.RhythmResult;
if (dbCorrection.Rhythm2Result == CorrectionReviewResult.Approved)
{
dbCorrection.AffectedThePoem = true;
var secondMetreSection = sections.First(s => s.SectionType == PoemSectionType.WholePoem && s.VerseType == VersePoemSectionType.Second);
if (secondMetreSection == null)
{
secondMetreSection = new GanjoorPoemSection()
{
PoemId = dbPoem.Id,
PoetId = mainSection.PoetId,
SectionType = PoemSectionType.WholePoem,
VerseType = VersePoemSectionType.Second,
Index = sections.Max(s => s.Index) + 1,
Number = sections.Max(s => s.Index) + 1 + 1,
GanjoorMetreId = null,
RhymeLetters = mainSection.RhymeLetters,
HtmlText = mainSection.HtmlText,
PlainText = mainSection.PlainText,
PoemFormat = mainSection.PoemFormat,
};
_context.Add(secondMetreSection);
}
secondMetreSection.OldGanjoorMetreId = secondMetreSection.GanjoorMetreId;
if (moderation.Rhythm == "")
{
secondMetreSection.GanjoorMetreId = null;
}
else
{
var metre = await _context.GanjoorMetres.AsNoTracking().Where(m => m.Rhythm == moderation.Rhythm).SingleOrDefaultAsync();
if (metre == null)
{
metre = new GanjoorMetre()
{
Rhythm = moderation.Rhythm,
VerseCount = 0
};
_context.GanjoorMetres.Add(metre);
await _context.SaveChangesAsync();
}
secondMetreSection.GanjoorMetreId = metre.Id;
}
metreChanged = mainSection.GanjoorMetreId != metre.Id;
mainSection.GanjoorMetreId = metre.Id;
}
}
@ -128,7 +182,7 @@ namespace RMuseum.Services.Implementation
await _context.SaveChangesAsync();
if (metreChanged || modifiedVerses.Count > 0)
if (modifiedVerses.Count > 0)
{
foreach (var section in sections)
{