Paginate the admin review queue (and flagged list)
The «صف بررسی» loaded every New/Flagged RawListing at once — endless scroll once a crawl fills it. Page both at 20/row with «قبلی/بعدی» controls (independent q & f query params); the header now shows the true totals, not the page size. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
<h1>پنل مدیریت — جمعآوری و صف آگهیها</h1>
|
<h1>پنل مدیریت — جمعآوری و صف آگهیها</h1>
|
||||||
<p class="muted">
|
<p class="muted">
|
||||||
آگهیهای جمعآوریشده از منابع را بررسی، ساختارمند و منتشر کن.
|
آگهیهای جمعآوریشده از منابع را بررسی، ساختارمند و منتشر کن.
|
||||||
(@JalaliDate.ToPersianDigits(Model.Queue.Count.ToString()) در صف،
|
(@JalaliDate.ToPersianDigits(Model.QueueTotal.ToString()) در صف،
|
||||||
@JalaliDate.ToPersianDigits(Model.Flagged.Count.ToString()) پرچمخورده)
|
@JalaliDate.ToPersianDigits(Model.FlaggedTotal.ToString()) پرچمخورده)
|
||||||
· <a asp-page="/Admin/Overview">داشبورد</a>
|
· <a asp-page="/Admin/Overview">داشبورد</a>
|
||||||
· <a asp-page="/Admin/Users">کاربران</a>
|
· <a asp-page="/Admin/Users">کاربران</a>
|
||||||
· <a asp-page="/Admin/Facilities">مراکز</a>
|
· <a asp-page="/Admin/Facilities">مراکز</a>
|
||||||
@@ -163,9 +163,19 @@
|
|||||||
{
|
{
|
||||||
<partial name="_RawListingRow" model="r" />
|
<partial name="_RawListingRow" model="r" />
|
||||||
}
|
}
|
||||||
|
@if (Model.QueuePages > 1)
|
||||||
|
{
|
||||||
|
<div class="row" style="display:flex; gap:10px; justify-content:center; align-items:center; margin-top:14px;">
|
||||||
|
@if (Model.QueuePage > 1)
|
||||||
|
{ <a class="btn btn-outline" asp-route-q="@(Model.QueuePage - 1)" asp-route-f="@Model.FlaggedPage">→ قبلی</a> }
|
||||||
|
<span class="muted">صفحه @JalaliDate.ToPersianDigits(Model.QueuePage.ToString()) از @JalaliDate.ToPersianDigits(Model.QueuePages.ToString())</span>
|
||||||
|
@if (Model.QueuePage < Model.QueuePages)
|
||||||
|
{ <a class="btn btn-outline" asp-route-q="@(Model.QueuePage + 1)" asp-route-f="@Model.FlaggedPage">بعدی ←</a> }
|
||||||
|
</div>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (Model.Flagged.Count > 0)
|
@if (Model.FlaggedTotal > 0)
|
||||||
{
|
{
|
||||||
<h2 style="font-size:20px; margin-top:28px;">پرچمخورده (ناقص/مشکوک)</h2>
|
<h2 style="font-size:20px; margin-top:28px;">پرچمخورده (ناقص/مشکوک)</h2>
|
||||||
<p class="muted" style="font-size:13px;">اعتبارسنجی اینها را کامل ندانست؛ در صورت صحت میتوانی منتشرشان کنی.</p>
|
<p class="muted" style="font-size:13px;">اعتبارسنجی اینها را کامل ندانست؛ در صورت صحت میتوانی منتشرشان کنی.</p>
|
||||||
@@ -173,6 +183,16 @@
|
|||||||
{
|
{
|
||||||
<partial name="_RawListingRow" model="r" />
|
<partial name="_RawListingRow" model="r" />
|
||||||
}
|
}
|
||||||
|
@if (Model.FlaggedPages > 1)
|
||||||
|
{
|
||||||
|
<div class="row" style="display:flex; gap:10px; justify-content:center; align-items:center; margin-top:14px;">
|
||||||
|
@if (Model.FlaggedPage > 1)
|
||||||
|
{ <a class="btn btn-outline" asp-route-q="@Model.QueuePage" asp-route-f="@(Model.FlaggedPage - 1)">→ قبلی</a> }
|
||||||
|
<span class="muted">صفحه @JalaliDate.ToPersianDigits(Model.FlaggedPage.ToString()) از @JalaliDate.ToPersianDigits(Model.FlaggedPages.ToString())</span>
|
||||||
|
@if (Model.FlaggedPage < Model.FlaggedPages)
|
||||||
|
{ <a class="btn btn-outline" asp-route-q="@Model.QueuePage" asp-route-f="@(Model.FlaggedPage + 1)">بعدی ←</a> }
|
||||||
|
</div>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ public class IndexModel : PageModel
|
|||||||
|
|
||||||
public List<RawListing> Queue { get; private set; } = new();
|
public List<RawListing> Queue { get; private set; } = new();
|
||||||
public List<RawListing> Flagged { get; private set; } = new();
|
public List<RawListing> Flagged { get; private set; } = new();
|
||||||
|
public const int PageSize = 20;
|
||||||
|
public int QueuePage { get; private set; } = 1;
|
||||||
|
public int QueueTotal { get; private set; }
|
||||||
|
public int FlaggedPage { get; private set; } = 1;
|
||||||
|
public int FlaggedTotal { get; private set; }
|
||||||
|
public int QueuePages => Math.Max(1, (int)Math.Ceiling(QueueTotal / (double)PageSize));
|
||||||
|
public int FlaggedPages => Math.Max(1, (int)Math.Ceiling(FlaggedTotal / (double)PageSize));
|
||||||
public IReadOnlyList<string> SourceNames { get; private set; } = new List<string>();
|
public IReadOnlyList<string> SourceNames { get; private set; } = new List<string>();
|
||||||
public int PublishedShifts { get; private set; }
|
public int PublishedShifts { get; private set; }
|
||||||
public int PublishedJobs { get; private set; }
|
public int PublishedJobs { get; private set; }
|
||||||
@@ -36,7 +43,7 @@ public class IndexModel : PageModel
|
|||||||
|
|
||||||
[TempData] public string? IngestMessage { get; set; }
|
[TempData] public string? IngestMessage { get; set; }
|
||||||
|
|
||||||
public async Task OnGetAsync() => await LoadAsync();
|
public async Task OnGetAsync(int q = 1, int f = 1) => await LoadAsync(q, f);
|
||||||
|
|
||||||
public async Task<IActionResult> OnPostAddAsync()
|
public async Task<IActionResult> OnPostAddAsync()
|
||||||
{
|
{
|
||||||
@@ -166,14 +173,21 @@ public class IndexModel : PageModel
|
|||||||
return RedirectToPage();
|
return RedirectToPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadAsync()
|
private async Task LoadAsync(int q = 1, int f = 1)
|
||||||
{
|
{
|
||||||
|
QueueTotal = await _db.RawListings.CountAsync(r => r.Status == RawListingStatus.New);
|
||||||
|
QueuePage = Math.Clamp(q, 1, QueuePages);
|
||||||
Queue = await _db.RawListings
|
Queue = await _db.RawListings
|
||||||
.Where(r => r.Status == RawListingStatus.New)
|
.Where(r => r.Status == RawListingStatus.New)
|
||||||
.OrderByDescending(r => r.Confidence).ThenByDescending(r => r.FetchedAt).ToListAsync();
|
.OrderByDescending(r => r.Confidence).ThenByDescending(r => r.FetchedAt)
|
||||||
|
.Skip((QueuePage - 1) * PageSize).Take(PageSize).ToListAsync();
|
||||||
|
|
||||||
|
FlaggedTotal = await _db.RawListings.CountAsync(r => r.Status == RawListingStatus.Flagged);
|
||||||
|
FlaggedPage = Math.Clamp(f, 1, FlaggedPages);
|
||||||
Flagged = await _db.RawListings
|
Flagged = await _db.RawListings
|
||||||
.Where(r => r.Status == RawListingStatus.Flagged)
|
.Where(r => r.Status == RawListingStatus.Flagged)
|
||||||
.OrderByDescending(r => r.FetchedAt).ToListAsync();
|
.OrderByDescending(r => r.FetchedAt)
|
||||||
|
.Skip((FlaggedPage - 1) * PageSize).Take(PageSize).ToListAsync();
|
||||||
SourceNames = _ingest.SourceNames;
|
SourceNames = _ingest.SourceNames;
|
||||||
PublishedShifts = await _db.Shifts.CountAsync(s => s.Source != ShiftSource.Direct);
|
PublishedShifts = await _db.Shifts.CountAsync(s => s.Source != ShiftSource.Direct);
|
||||||
PublishedJobs = await _db.JobOpenings.CountAsync();
|
PublishedJobs = await _db.JobOpenings.CountAsync();
|
||||||
|
|||||||
Reference in New Issue
Block a user