fix(mail): search every owned job
Replace ineffective pageSize=100 selectors with a bounded owner-filtered search endpoint for composing and moving linked threads.
This commit is contained in:
@@ -15,6 +15,8 @@ using static JobTrackerApi.Services.JobApplicationHelpers;
|
||||
|
||||
namespace JobTrackerApi.Controllers
|
||||
{
|
||||
public sealed record JobApplicationChoiceDto(int Id, string JobTitle, string CompanyName);
|
||||
|
||||
[ApiController]
|
||||
// Explicitly authorized. These endpoints are all tenant-scoped user data, so they must not
|
||||
// depend on the Auth:Require fallback policy being switched on: a deployment that lost that flag
|
||||
@@ -2268,6 +2270,31 @@ Job description:
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("choices")]
|
||||
public async Task<ActionResult<List<JobApplicationChoiceDto>>> GetChoices(
|
||||
[FromQuery] string? q = null,
|
||||
[FromQuery] int limit = 20,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
limit = Math.Clamp(limit, 1, 50);
|
||||
var query = _db.JobApplications.AsNoTracking()
|
||||
.Where(item => !item.IsDeleted);
|
||||
if (!string.IsNullOrWhiteSpace(q))
|
||||
{
|
||||
var like = $"%{q.Trim()}%";
|
||||
query = query.Where(item =>
|
||||
EF.Functions.Like(item.JobTitle, like) ||
|
||||
EF.Functions.Like(item.Company.Name, like));
|
||||
}
|
||||
|
||||
return Ok(await query
|
||||
.OrderByDescending(item => item.DateApplied ?? item.SavedAt)
|
||||
.ThenByDescending(item => item.Id)
|
||||
.Select(item => new JobApplicationChoiceDto(item.Id, item.JobTitle, item.Company.Name))
|
||||
.Take(limit)
|
||||
.ToListAsync(cancellationToken));
|
||||
}
|
||||
|
||||
[HttpGet("ai-metrics")]
|
||||
[HttpGet("summarizer-metrics")]
|
||||
public async Task<ActionResult<AiServiceMetrics>> GetSummarizerMetrics(CancellationToken cancellationToken)
|
||||
|
||||
Reference in New Issue
Block a user