poem formats in stats page
This commit is contained in:
parent
4dd5bea160
commit
d61fd419a3
@ -65,6 +65,8 @@ namespace RMuseum.Services.Implementation
|
||||
return "چند بندی";
|
||||
case GanjoorPoemFormat.BahreTavil:
|
||||
return "بحر طویل";
|
||||
case GanjoorPoemFormat.Unknown:
|
||||
return "نامشخص";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -28,6 +28,13 @@ namespace RMuseum.Services.Implementation
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
||||
internal class PoemFormatCoupletCount
|
||||
{
|
||||
public GanjoorPoemFormat Format { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IGanjoorService implementation
|
||||
/// </summary>
|
||||
@ -329,6 +336,45 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
languagesCoupletsCountsUnprocessed.Sort((a, b) => b.Count - a.Count);
|
||||
|
||||
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 1, "Counting Poem Formats");
|
||||
var formatsResult = await (from v in context.GanjoorVerses.AsNoTracking().Include(v => v.Poem).ThenInclude(p => p.Cat).ThenInclude(c => c.Poet)
|
||||
from s in context.GanjoorPoemSections
|
||||
where v.PoemId == s.PoemId && v.SectionIndex1 == s.Index && s.SectionType == PoemSectionType.WholePoem
|
||||
&&
|
||||
v.Poem.Cat.Poet.Published
|
||||
&&
|
||||
(v.VersePosition == VersePosition.Right || v.VersePosition == VersePosition.CenteredVerse1)
|
||||
group s.PoemFormat by s.PoemFormat into g
|
||||
select new { PoemFormat = g.Key, Count = g.Count() }).ToListAsync();
|
||||
|
||||
|
||||
List<PoemFormatCoupletCount> formatCoupletsCountsUnprocessed = new List<PoemFormatCoupletCount>
|
||||
{
|
||||
new PoemFormatCoupletCount()
|
||||
{
|
||||
Format = GanjoorPoemFormat.Unknown,
|
||||
Count = 0
|
||||
}
|
||||
};
|
||||
foreach (var item in formatsResult)
|
||||
{
|
||||
if (item.PoemFormat == null || item.PoemFormat == GanjoorPoemFormat.Unknown)
|
||||
{
|
||||
var fa = formatCoupletsCountsUnprocessed.Where(l => l.Format == GanjoorPoemFormat.Unknown).Single();
|
||||
fa.Count += item.Count;
|
||||
}
|
||||
else
|
||||
formatCoupletsCountsUnprocessed.Add(new PoemFormatCoupletCount()
|
||||
{
|
||||
Format = (GanjoorPoemFormat)item.PoemFormat,
|
||||
Count = item.Count
|
||||
});
|
||||
}
|
||||
|
||||
formatCoupletsCountsUnprocessed.Sort((a, b) => b.Count - a.Count);
|
||||
|
||||
|
||||
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 1, "Counting whole sections");
|
||||
|
||||
@ -444,6 +490,32 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
htmlText += $"</table>{Environment.NewLine}";
|
||||
|
||||
htmlText += $"<p>آمار ابیات برچسبگذاری شده با قالب شعری در گنجور به شرح زیر است:</p>{Environment.NewLine}";
|
||||
|
||||
htmlText += $"<table>{Environment.NewLine}" +
|
||||
$"<tr class=\"h\">{Environment.NewLine}" +
|
||||
$"<td class=\"c1\">ردیف</td>{Environment.NewLine}" +
|
||||
$"<td class=\"c2\">قالب شعری</td>{Environment.NewLine}" +
|
||||
$"<td class=\"c3\">تعداد ابیات</td>{Environment.NewLine}" +
|
||||
$"<td class=\"c4\">درصد از کل</td>{Environment.NewLine}" +
|
||||
$"</tr>{Environment.NewLine}";
|
||||
|
||||
for (int i = 0; i < formatCoupletsCountsUnprocessed.Count; i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
htmlText += $"<tr class=\"e\">{Environment.NewLine}";
|
||||
else
|
||||
htmlText += $"<tr>{Environment.NewLine}";
|
||||
|
||||
htmlText += $"<td class=\"c1\">{(i + 1).ToPersianNumbers()}</td>{Environment.NewLine}";
|
||||
htmlText += $"<td class=\"c2\"><a href=\"/simi/?f={(int)formatCoupletsCountsUnprocessed[i].Format}\">{GanjoorPoemFormatConvertor.GetString(formatCoupletsCountsUnprocessed[i].Format)}</a></td>{Environment.NewLine}";
|
||||
htmlText += $"<td class=\"c3\">{LanguageUtils.FormatMoney(formatCoupletsCountsUnprocessed[i].Count)}</td>{Environment.NewLine}";
|
||||
htmlText += $"<td class=\"c4\">{(formatCoupletsCountsUnprocessed[i].Count * 100.0 / sumPoetsCouplets).ToString("N2", new CultureInfo("fa-IR")).ToPersianNumbers()}</td>{Environment.NewLine}";
|
||||
|
||||
htmlText += $"</tr>{Environment.NewLine}";
|
||||
}
|
||||
htmlText += $"</table>{Environment.NewLine}";
|
||||
|
||||
|
||||
|
||||
var rhythms = await context.GanjoorMetres.ToListAsync();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user