stats for poems couplet counts in categories

#464
This commit is contained in:
Hamid Reza Mohammadi 2025-01-28 13:30:25 +03:30
parent 801e793de7
commit ea89232e1d
2 changed files with 39 additions and 3 deletions

View File

@ -270,7 +270,12 @@
}
</select>
<label for="f" class="width-100per">کلیدواژه (جستجو در کل صفحهٔ شعر، برای جستجوی بهتر از <a href="/search?s=@Model.Query">صفحهٔ جستجو</a> استفاده کنید):</label>
<label for="c1" class="width-100per">حداقل تعداد ابیات:</label>
<input type="number" name="c1" id="c1" class="width-100per" value="@Model.CoupletCountsFrom" placeholder="حداقل تعداد ابیات" />
<label for="c2" class="width-100per">حداکثر تعداد ابیات:</label>
<input type="number" name="c2" id="c2" class="width-100per" value="@Model.CoupletCountsTo" placeholder="حداکثر تعداد ابیات" />
<label class="width-100per">کلیدواژه (جستجو در کل صفحهٔ شعر، برای جستجوی بهتر از <a href="/search?s=@Model.Query">صفحهٔ جستجو</a> استفاده کنید):</label>
<input type="text" name="s" id="s" class="width-100per" value="@Model.Query" placeholder="کلیدواژه" />
@if (Model.ExactSearch)
{

View File

@ -72,6 +72,8 @@ namespace GanjooRazor.Pages
public string CatFullUrl { get; set; }
public string Metre { get; set; }
public string Rhyme { get; set; }
public int CoupletCountsFrom { get; set; }
public int CoupletCountsTo { get; set; }
public GanjoorLanguage[] Languages { get; set; }
public GanjoorPoetCompleteViewModel Poet { get; set; }
public List<GanjoorPoemCompleteViewModel> Poems { get; set; }
@ -286,6 +288,24 @@ namespace GanjooRazor.Pages
Rhyme = Rhyme.Replace(" ", "");
}
CoupletCountsFrom = 0;
if (!string.IsNullOrEmpty(Request.Query["c1"]))
{
if(int.TryParse(Request.Query["c1"], out int i))
{
CoupletCountsFrom = i;
}
}
CoupletCountsTo = 0;
if (!string.IsNullOrEmpty(Request.Query["c2"]))
{
if (int.TryParse(Request.Query["c2"], out int i))
{
CoupletCountsTo = i;
}
}
if (!anyParamsGiven)
{
@ -324,6 +344,7 @@ namespace GanjooRazor.Pages
title += $" حروف قافیهٔ «{Rhyme}»";
}
if(Language != "fa-IR")
{
var langModel = Languages.Where(l => l.Code == Language).FirstOrDefault();
@ -338,7 +359,17 @@ namespace GanjooRazor.Pages
title += $" در قالب شعری «{GanjoorPoemFormatConvertor.GetString(Format)}»";
}
if(CatId != 0)
if (CoupletCountsFrom != 0)
{
title += $" حداقل تعداد ابیات «{CoupletCountsFrom.ToPersianNumbers()}»";
}
if (CoupletCountsTo != 0)
{
title += $" حداکثر تعداد ابیات «{CoupletCountsTo.ToPersianNumbers()}»";
}
if (CatId != 0)
{
var catResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/cat/{CatId}?poems=false&mainSections=false");
if (!catResponse.IsSuccessStatusCode)
@ -372,7 +403,7 @@ namespace GanjooRazor.Pages
title += $" شامل کلیدواژهٔ «{Query}»";
}
string url = $"{APIRoot.Url}/api/ganjoor/poems/similar?PageNumber={pageNumber}&PageSize=20&metre={Metre}&rhyme={Rhyme}&poetId={PoetId}&catId={CatId}&language={Language}&format={(int)Format}";
string url = $"{APIRoot.Url}/api/ganjoor/poems/similar?PageNumber={pageNumber}&PageSize=20&metre={Metre}&rhyme={Rhyme}&poetId={PoetId}&catId={CatId}&language={Language}&format={(int)Format}&c1={CoupletCountsFrom}&c2={CoupletCountsTo}";
if(!string.IsNullOrEmpty(Query))
{
url += $"&term={Query}";