AI qualify: de-dupe applicants, base roles, closed categories, tag hygiene + reprocess-stored action
Qualified live applicants and found three problems, all fixed: - Duplicate cards: one ad fanned out into «پرستار» + «پرستار کودک» (same person). Applicants now publish ONE listing (no role fan-out); secondary roles → tags. - Role sprawl: modifiers became roles. Prompt now returns the BASE profession and pushes age-group/ward/seniority to tags; new roles only for a genuinely new base profession (تکنسین داروخانه ✓, پرستار کودک ✗). - Tag/category noise: categories pinned to the 5 fixed groups (+سایر, never invented); BuildTags drops pay/contact/location/fragment words. Reprocess action: IngestionService.ReprocessAsync re-runs the current pipeline over every stored RawListing WITHOUT re-fetching (keeps the raw text, so nothing is lost to sources only exposing recent posts), deleting the old aggregated posts and republishing cleanly. Admin dashboard button «پردازش مجددِ آیتمهای ذخیرهشده» runs it on a background scope; result lands in the run-log. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -49,6 +49,15 @@
|
||||
کش حذف تکراری و آگهیهای جمعآوریشده پاک و از نو با AI پردازش میشوند. (آگهیهای مراکز حذف نمیشوند.)
|
||||
</p>
|
||||
|
||||
<form method="post" onsubmit="return confirm('آگهیهای منتشرشده از جمعآوری حذف و از روی متنِ خامِ ذخیرهشده (بدون واکشی مجدد) دوباره با هوش مصنوعی پردازش میشوند — برای پاکسازی دادههای موجود (حذف موارد تکراری، اصلاح نقش/گروه/تگ). هیچ آیتمی از دست نمیرود. در پسزمینه اجرا میشود. ادامه؟');">
|
||||
<button type="submit" asp-page-handler="ReprocessStored" class="btn btn-primary btn-block" style="margin-top:10px;">
|
||||
🧹 پردازش مجددِ آیتمهای ذخیرهشده (بدون واکشی)
|
||||
</button>
|
||||
</form>
|
||||
<p class="muted" style="font-size:11px; margin:6px 0 0;">
|
||||
توصیهشده برای پاکسازیِ دادههای فعلی: متنِ خام نگه داشته میشود و فقط آگهیها با منطقِ جدید (یکنفر=یکآگهی، نقش پایه، گروه ثابت، تگ تمیز) بازساخته میشوند.
|
||||
</p>
|
||||
|
||||
<hr style="border:none; border-top:1px solid var(--line); margin:16px 0;" />
|
||||
|
||||
<h3>افزودن دستی</h3>
|
||||
|
||||
@@ -13,11 +13,15 @@ public class IndexModel : PageModel
|
||||
{
|
||||
private readonly AppDbContext _db;
|
||||
private readonly IngestionService _ingest;
|
||||
private readonly IServiceScopeFactory _scopes;
|
||||
private readonly ILogger<IndexModel> _log;
|
||||
|
||||
public IndexModel(AppDbContext db, IngestionService ingest)
|
||||
public IndexModel(AppDbContext db, IngestionService ingest, IServiceScopeFactory scopes, ILogger<IndexModel> log)
|
||||
{
|
||||
_db = db;
|
||||
_ingest = ingest;
|
||||
_scopes = scopes;
|
||||
_log = log;
|
||||
}
|
||||
|
||||
public List<RawListing> Queue { get; private set; } = new();
|
||||
@@ -94,6 +98,26 @@ public class IndexModel : PageModel
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up EXISTING aggregated content by re-running the current pipeline over the stored raw
|
||||
/// text — no re-fetch, so nothing is lost to sources only exposing recent posts. Long-running
|
||||
/// (one AI call per item), so it runs on a background scope and returns immediately; the result
|
||||
/// shows up as a new row in the «تاریخچهٔ اجرا» log when it finishes.
|
||||
/// </summary>
|
||||
public IActionResult OnPostReprocessStored()
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
using var scope = _scopes.CreateScope();
|
||||
var svc = scope.ServiceProvider.GetRequiredService<IngestionService>();
|
||||
var log = scope.ServiceProvider.GetRequiredService<ILogger<IndexModel>>();
|
||||
try { await svc.ReprocessAsync(); }
|
||||
catch (Exception ex) { log.LogError(ex, "Background reprocess failed"); }
|
||||
});
|
||||
IngestMessage = "پردازش مجدد آیتمهای ذخیرهشده در پسزمینه آغاز شد. نتیجه پس از اتمام در «تاریخچهٔ اجرا» نمایش داده میشود (بسته به تعداد آیتمها و سرعت هوش مصنوعی، چند دقیقه طول میکشد).";
|
||||
return RedirectToPage();
|
||||
}
|
||||
|
||||
private async Task LoadAsync()
|
||||
{
|
||||
Queue = await _db.RawListings
|
||||
|
||||
Reference in New Issue
Block a user