From 684bb0e29d95cb3e28ec0ac41eddb91cfb581730 Mon Sep 17 00:00:00 2001
From: Hamid Reza Mohammadi
Date: Tue, 28 Jan 2025 15:46:36 +0330
Subject: [PATCH] stats for poems couplet counts in categories #464
---
.../Areas/Admin/Pages/ModifyPage.cshtml | 2 ++
.../Areas/Admin/Pages/ModifyPage.cshtml.cs | 19 +++++++++++++++++
GanjooRazor/Pages/Shared/_AdminLayout.cshtml | 21 +++++++++++++++++++
GanjooRazor/Pages/_GanjoorPagePartial.cshtml | 12 ++++++++++-
4 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml b/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml
index 52892f96..322ef2da 100644
--- a/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml
+++ b/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml
@@ -323,6 +323,8 @@
بازسازی نقشهٔ سایت تاجیکی
+ بازشماری تعداد ابیات قطعات
+
بازسازی صفحات آمار و اوزان عروضی
بازسازی صفحات استقبالها
diff --git a/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml.cs b/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml.cs
index 7e305a86..77edd4eb 100644
--- a/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml.cs
+++ b/GanjooRazor/Areas/Admin/Pages/ModifyPage.cshtml.cs
@@ -340,6 +340,25 @@ namespace GanjooRazor.Areas.Admin.Pages
}
+ public async Task OnPostRefillSectionsCoupletCountsAsync()
+ {
+ using (HttpClient secureClient = new HttpClient())
+ {
+ if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
+ {
+ HttpResponseMessage response = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/fillsectioncoupletcounts", null);
+ if (!response.IsSuccessStatusCode)
+ {
+ return BadRequest(JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()));
+ }
+ return new OkObjectResult(true);
+ }
+ }
+ return new OkObjectResult(false);
+ }
+
+
+
public async Task OnPostRebuildRelatedPagesAsync()
{
diff --git a/GanjooRazor/Pages/Shared/_AdminLayout.cshtml b/GanjooRazor/Pages/Shared/_AdminLayout.cshtml
index a32d63cd..0fa0aeb5 100644
--- a/GanjooRazor/Pages/Shared/_AdminLayout.cshtml
+++ b/GanjooRazor/Pages/Shared/_AdminLayout.cshtml
@@ -181,6 +181,27 @@
});
}
+
+
+ function refillCoupletCounts() {
+ if (!confirm('آیا از بازشماری تعداد ابیات قطعات اطمینان دارید؟'))
+ return;
+
+ var url = '?handler=RefillSectionsCoupletCounts';
+
+ $.ajax({
+ type: "POST",
+ url: url,
+ error: function() {
+ alert('خطا رخ داد.')
+ },
+ success: function() {
+ alert('فرایند بازشماری تعداد ابیات قطعات شروع شد.')
+ },
+
+ });
+ }
+
function rebuildRelatedPages() {
if (!confirm('آیا از بازسازی محتوای صفحات استقبالها اطمینان دارید؟'))
return;
diff --git a/GanjooRazor/Pages/_GanjoorPagePartial.cshtml b/GanjooRazor/Pages/_GanjoorPagePartial.cshtml
index 2cd5aa2c..333c0312 100644
--- a/GanjooRazor/Pages/_GanjoorPagePartial.cshtml
+++ b/GanjooRazor/Pages/_GanjoorPagePartial.cshtml
@@ -415,7 +415,7 @@
با انتخاب متن و لمس متن انتخابی میتوانید آن را در لغتنامهٔ دهخدا جستجو کنید.
- @if (Model.GanjoorPage.Poem.Sections.Where(s => s.SectionType == RMuseum.Models.Ganjoor.PoemSectionType.WholePoem && s.GanjoorMetre != null).Any() || !string.IsNullOrEmpty(Model.GanjoorPage.Poem.OldTag) || !string.IsNullOrEmpty(Model.GanjoorPage.Poem.SourceName))
+ @if (Model.GanjoorPage.Poem.Sections.Where(s => s.SectionType == RMuseum.Models.Ganjoor.PoemSectionType.WholePoem).Any() || !string.IsNullOrEmpty(Model.GanjoorPage.Poem.OldTag) || !string.IsNullOrEmpty(Model.GanjoorPage.Poem.SourceName))
{
@if (!Model.MutiPartPoemPage)
@@ -476,6 +476,16 @@
}
+
+ |
+ تعداد ابیات:
+ |
+
+ @Model.GanjoorPage.Poem.Sections.Where(s => s.SectionType == RMuseum.Models.Ganjoor.PoemSectionType.WholePoem).Sum(s => s.CoupletsCount).ToPersianNumbers()
+ |
+
+
+
}