Collapse the sprawling role taxonomy (dedupe/compound/typo merge)
CI/CD / CI · dotnet build (push) Successful in 2m46s
CI/CD / Deploy · hamkadr (push) Successful in 2m5s

The dynamic taxonomy minted ~150 roles incl. exact triplicates («پرستار کودک» x3), multi-role
compounds («پرستار و بهیار»، «ماما / پرستار»، «پزشک و پرستار و بهیار»), and typos («بیهیار»، «بیار»).

Creation hardening: ResolveOrCreateRole now collapses a compound to its FIRST base role when that
segment is a known role (so «پرستار و بهیار»→«پرستار», but specialty names like «قلب و عروق»/«پوست
و مو» are left whole), and new aliases fold typos/synonyms (بیهیار/بیار→بهیار، فیزیوتراپ→فیزیوتراپیست،
نسخه پیچ→تکنسین داروخانه، پرستار بچه/اطفال→پرستار کودک).

Cleanup: MergeDuplicateRolesAsync (+ admin button) maps every role to a canonical form and merges
same-canonical roles into one keeper, repointing all shifts/jobs/talent/preferences/alerts/profiles
first (mirrors the manual /Admin/Roles merge). Combined with the no-fan-out change this should cut
the dropdown to a clean base set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-21 21:35:43 +03:30
parent 2b7ac96472
commit b223d3af2d
3 changed files with 84 additions and 0 deletions
@@ -87,6 +87,15 @@
🩺 اصلاح نقشِ آگهی‌های «پزشک عمومی» (دندانپزشک/متخصص و …)
</button>
</form>
<form method="post" onsubmit="return confirm('نقش‌های تکراری/ترکیبی/غلط‌املایی (مثل «پرستار کودک» سه‌تایی، «پرستار و بهیار»، «بیهیار») در نقش‌های اصلی ادغام و حذف می‌شوند؛ آگهی‌هایشان به نقشِ معتبر منتقل می‌شود. ادامه؟');">
<button type="submit" asp-page-handler="MergeRoles" class="btn btn-primary btn-block" style="margin-top:10px;">
🏷️ ادغام نقش‌های تکراری/ترکیبی/غلط‌املایی
</button>
</form>
<p class="muted" style="font-size:11px; margin:6px 0 0;">
نقش‌های هم‌معنا (تکراری، ترکیبی مثل «پرستار و بهیار»، یا غلط‌املایی مثل «بیهیار») در یک نقشِ پایه ادغام می‌شوند تا فهرستِ نقش‌ها تمیز شود. مدیریتِ دستی در <a asp-page="/Admin/Roles">نقش‌ها</a>.
</p>
<p class="muted" style="font-size:11px; margin:6px 0 0;">
آگهی‌هایی که هوش مصنوعی به اشتباه «پزشک عمومی» زده ولی متنشان نقش دیگری دارد، از روی متن اصلاح می‌شوند (درجا، بدون تغییر شناسه/آدرس).
</p>
@@ -173,6 +173,15 @@ public class IndexModel : PageModel
return RedirectToPage();
}
/// <summary>Auto-merge duplicate/compound/typo roles minted by the dynamic taxonomy
/// («پرستار کودک» ×3، «پرستار و بهیار»، «بیهیار»→بهیار), repointing all listings first.</summary>
public async Task<IActionResult> OnPostMergeRolesAsync()
{
var n = await _ingest.MergeDuplicateRolesAsync();
IngestMessage = $"پاک‌سازی نقش‌ها: {n} نقشِ تکراری/ترکیبی/غلط‌املایی در نقش‌های اصلی ادغام شد (آگهی‌هایشان منتقل شد). فهرست نقش‌ها اکنون تمیزتر است.";
return RedirectToPage();
}
private async Task LoadAsync(int q = 1, int f = 1)
{
QueueTotal = await _db.RawListings.CountAsync(r => r.Status == RawListingStatus.New);