Show job counts, not shifts-only, on public pages
The platform has ~1600 open استخدام but only ~4 dated شیفت (the VPN-free sources are hiring boards, not shift channels), so the shifts-only counters read misleadingly low: - Homepage stat pill «۴ شیفت باز» -> «موقعیت استخدام» (open job count). - Facility cards «۰ شیفت باز» -> «N آگهی فعال» = open shifts + open (fresh) jobs, so a facility that is hiring no longer reads zero. Also hide the «نامشخص / ثبت نشده» placeholder from the facilities list and sort active facilities (then verified, then name) first, so real hiring centers surface. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<div class="foot" style="display:flex; justify-content:space-between; align-items:center; border-top:1px solid var(--line); padding-top:12px;">
|
<div class="foot" style="display:flex; justify-content:space-between; align-items:center; border-top:1px solid var(--line); padding-top:12px;">
|
||||||
<span class="pay" style="color:var(--primary-dark); font-weight:800;">
|
<span class="pay" style="color:var(--primary-dark); font-weight:800;">
|
||||||
@JalaliDate.ToPersianDigits(row.OpenShifts.ToString()) شیفت باز
|
@JalaliDate.ToPersianDigits(row.OpenListings.ToString()) آگهی فعال
|
||||||
</span>
|
</span>
|
||||||
<span class="btn btn-outline" style="padding:6px 14px;">مشاهده مرکز</span>
|
<span class="btn btn-outline" style="padding:6px 14px;">مشاهده مرکز</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,21 +10,36 @@ public class IndexModel : PageModel
|
|||||||
private readonly AppDbContext _db;
|
private readonly AppDbContext _db;
|
||||||
public IndexModel(AppDbContext db) => _db = db;
|
public IndexModel(AppDbContext db) => _db = db;
|
||||||
|
|
||||||
public record FacilityRow(Facility Facility, int OpenShifts);
|
public record FacilityRow(Facility Facility, int OpenListings);
|
||||||
public List<FacilityRow> Rows { get; private set; } = new();
|
public List<FacilityRow> Rows { get; private set; } = new();
|
||||||
|
|
||||||
|
// The shared placeholder for unnamed aggregated ads is not a real, browseable facility.
|
||||||
|
private const string PlaceholderName = "نامشخص / ثبت نشده";
|
||||||
|
|
||||||
public async Task OnGetAsync()
|
public async Task OnGetAsync()
|
||||||
{
|
{
|
||||||
var today = DateOnly.FromDateTime(DateTime.UtcNow);
|
var today = DateOnly.FromDateTime(DateTime.UtcNow);
|
||||||
var facilities = await _db.Facilities.Include(f => f.City).OrderBy(f => f.Name).ToListAsync();
|
var jobCutoff = JobsMedical.Web.Services.Scraping.ListingPolicy.JobCutoffUtc;
|
||||||
var counts = await _db.Shifts
|
|
||||||
|
var facilities = await _db.Facilities.Include(f => f.City)
|
||||||
|
.Where(f => f.Name != PlaceholderName).ToListAsync();
|
||||||
|
|
||||||
|
// "Active listings" = open shifts + open (fresh) job openings — a facility that is hiring
|
||||||
|
// shouldn't read «۰ شیفت باز» just because it posted a job rather than a dated shift.
|
||||||
|
var shiftCounts = await _db.Shifts
|
||||||
.Where(s => s.Status == ShiftStatus.Open && s.Date >= today)
|
.Where(s => s.Status == ShiftStatus.Open && s.Date >= today)
|
||||||
.GroupBy(s => s.FacilityId)
|
.GroupBy(s => s.FacilityId).Select(g => new { g.Key, C = g.Count() })
|
||||||
.Select(g => new { g.Key, Count = g.Count() })
|
.ToDictionaryAsync(x => x.Key, x => x.C);
|
||||||
.ToDictionaryAsync(x => x.Key, x => x.Count);
|
var jobCounts = await _db.JobOpenings
|
||||||
|
.Where(j => j.Status == ShiftStatus.Open && j.CreatedAt >= jobCutoff)
|
||||||
|
.GroupBy(j => j.FacilityId).Select(g => new { g.Key, C = g.Count() })
|
||||||
|
.ToDictionaryAsync(x => x.Key, x => x.C);
|
||||||
|
|
||||||
Rows = facilities
|
Rows = facilities
|
||||||
.Select(f => new FacilityRow(f, counts.GetValueOrDefault(f.Id)))
|
.Select(f => new FacilityRow(f, shiftCounts.GetValueOrDefault(f.Id) + jobCounts.GetValueOrDefault(f.Id)))
|
||||||
|
.OrderByDescending(r => r.OpenListings) // active facilities first
|
||||||
|
.ThenByDescending(r => r.Facility.IsVerified)
|
||||||
|
.ThenBy(r => r.Facility.Name)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="stat-pills">
|
<div class="stat-pills">
|
||||||
<div class="stat-pill"><span class="n">@JalaliDate.ToPersianDigits(Model.OpenShiftCount.ToString())</span><span class="l">شیفت باز</span></div>
|
<div class="stat-pill"><span class="n">@JalaliDate.ToPersianDigits(Model.OpenJobCount.ToString())</span><span class="l">موقعیت استخدام</span></div>
|
||||||
<div class="stat-pill"><span class="n">@JalaliDate.ToPersianDigits(Model.FacilityCount.ToString())</span><span class="l">مرکز درمانی</span></div>
|
<div class="stat-pill"><span class="n">@JalaliDate.ToPersianDigits(Model.FacilityCount.ToString())</span><span class="l">مرکز درمانی</span></div>
|
||||||
<div class="stat-pill"><span class="n">@JalaliDate.ToPersianDigits(Model.CityCount.ToString())</span><span class="l">شهر فعال</span></div>
|
<div class="stat-pill"><span class="n">@JalaliDate.ToPersianDigits(Model.CityCount.ToString())</span><span class="l">شهر فعال</span></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class IndexModel : PageModel
|
|||||||
public List<City> Cities { get; private set; } = new();
|
public List<City> Cities { get; private set; } = new();
|
||||||
public List<Role> Roles { get; private set; } = new();
|
public List<Role> Roles { get; private set; } = new();
|
||||||
public int OpenShiftCount { get; private set; }
|
public int OpenShiftCount { get; private set; }
|
||||||
|
public int OpenJobCount { get; private set; }
|
||||||
public int FacilityCount { get; private set; }
|
public int FacilityCount { get; private set; }
|
||||||
public int CityCount { get; private set; }
|
public int CityCount { get; private set; }
|
||||||
|
|
||||||
@@ -68,6 +69,8 @@ public class IndexModel : PageModel
|
|||||||
Cities = await _db.Cities.Where(c => c.IsActive).OrderBy(c => c.Name).ToListAsync();
|
Cities = await _db.Cities.Where(c => c.IsActive).OrderBy(c => c.Name).ToListAsync();
|
||||||
Roles = await _db.Roles.Where(r => r.IsActive).OrderBy(r => r.SortOrder).ToListAsync();
|
Roles = await _db.Roles.Where(r => r.IsActive).OrderBy(r => r.SortOrder).ToListAsync();
|
||||||
OpenShiftCount = await _db.Shifts.CountAsync(s => s.Status == ShiftStatus.Open && s.Date >= today);
|
OpenShiftCount = await _db.Shifts.CountAsync(s => s.Status == ShiftStatus.Open && s.Date >= today);
|
||||||
|
OpenJobCount = await _db.JobOpenings.CountAsync(j => j.Status == ShiftStatus.Open
|
||||||
|
&& j.CreatedAt >= JobsMedical.Web.Services.Scraping.ListingPolicy.JobCutoffUtc);
|
||||||
FacilityCount = await _db.Facilities.CountAsync();
|
FacilityCount = await _db.Facilities.CountAsync();
|
||||||
CityCount = await _db.Cities.CountAsync(c => c.IsActive);
|
CityCount = await _db.Cities.CountAsync(c => c.IsActive);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user