Files
hamkadr/src/JobsMedical.Web/Pages/Index.cshtml.cs
T
soroush.asadi 6d2ad6f87e
CI/CD / CI · dotnet build (push) Successful in 37s
CI/CD / Deploy · hamkadr (push) Successful in 48s
Hide + archive stale listings (old jobs, expired shifts)
- ListingPolicy.JobFreshnessDays=30: public /Jobs and home hide jobs older than the cutoff (shifts already require Date>=today)
- ListingArchiver flips stale Open→Expired: shifts past their date, jobs older than the cutoff. Runs at startup and on every IngestionWorker cycle (independent of ingestion being enabled)
- Verified: backdated job dropped off /Jobs (6→5) and was archived to Expired on the sweep

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 09:57:06 +03:30

66 lines
2.7 KiB
C#

using JobsMedical.Web.Data;
using JobsMedical.Web.Models;
using JobsMedical.Web.Services;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
namespace JobsMedical.Web.Pages;
public class IndexModel : PageModel
{
private readonly AppDbContext _db;
private readonly RecommendationService _recs;
private readonly InterestService _interest;
public IndexModel(AppDbContext db, RecommendationService recs, InterestService interest)
{
_db = db;
_recs = recs;
_interest = interest;
}
public List<Recommendation> Recommendations { get; private set; } = new();
public bool HasPersonalization { get; private set; }
public List<Shift> LatestShifts { get; private set; } = new();
public List<JobOpening> LatestJobs { get; private set; } = new();
public List<City> Cities { get; private set; } = new();
public List<Role> Roles { get; private set; } = new();
public int OpenShiftCount { get; private set; }
public int FacilityCount { get; private set; }
public int CityCount { get; private set; }
public async Task OnGetAsync()
{
var today = DateOnly.FromDateTime(DateTime.UtcNow);
Recommendations = await _recs.GetForVisitorAsync(6);
// "Personalized" = we actually used a signal (prefs or behavior), not just cold-start freshness.
HasPersonalization = (await _interest.GetPreferencesAsync())?.HasAny == true
|| (await _interest.RecentEventsAsync(1)).Count > 0;
LatestShifts = await _db.Shifts
.Include(s => s.Facility).ThenInclude(f => f.City)
.Include(s => s.Role)
.Where(s => s.Status == ShiftStatus.Open && s.Date >= today)
.OrderBy(s => s.Date).ThenBy(s => s.StartTime)
.Take(6)
.ToListAsync();
LatestJobs = await _db.JobOpenings
.Include(j => j.Facility).ThenInclude(f => f.City)
.Include(j => j.Facility).ThenInclude(f => f.District)
.Include(j => j.Role)
.Where(j => j.Status == ShiftStatus.Open
&& j.CreatedAt >= JobsMedical.Web.Services.Scraping.ListingPolicy.JobCutoffUtc)
.OrderByDescending(j => j.CreatedAt)
.Take(3)
.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();
OpenShiftCount = await _db.Shifts.CountAsync(s => s.Status == ShiftStatus.Open && s.Date >= today);
FacilityCount = await _db.Facilities.CountAsync();
CityCount = await _db.Cities.CountAsync(c => c.IsActive);
}
}