fix(mail): search every owned job
CI and Deploy / test (pull_request) Successful in 5m13s
CI and Deploy / deploy (pull_request) Has been skipped

Replace ineffective pageSize=100 selectors with a bounded owner-filtered search endpoint for composing and moving linked threads.
This commit is contained in:
cesnimda
2026-08-15 20:13:14 +02:00
parent dc511296a4
commit a08ba9b45d
9 changed files with 167 additions and 57 deletions
@@ -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)