Add attachment selection controls and lazy-load app screens
This commit is contained in:
@@ -79,11 +79,28 @@ namespace JobTrackerApi.Controllers
|
||||
|
||||
private sealed record AttachmentContextResult(string Context, List<string> Signals, List<string> UsedFiles);
|
||||
|
||||
private async Task<AttachmentContextResult?> BuildAttachmentContextAsync(int jobId, CancellationToken cancellationToken)
|
||||
private async Task<AttachmentContextResult?> BuildAttachmentContextAsync(int jobId, CancellationToken cancellationToken, string? attachmentIdsCsv = null)
|
||||
{
|
||||
var attachments = await _db.Attachments
|
||||
HashSet<int>? allowedIds = null;
|
||||
if (!string.IsNullOrWhiteSpace(attachmentIdsCsv))
|
||||
{
|
||||
allowedIds = attachmentIdsCsv
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||
.Select(value => int.TryParse(value, out var id) ? id : 0)
|
||||
.Where(id => id > 0)
|
||||
.ToHashSet();
|
||||
}
|
||||
|
||||
var query = _db.Attachments
|
||||
.AsNoTracking()
|
||||
.Where(a => a.JobApplicationId == jobId)
|
||||
.Where(a => a.JobApplicationId == jobId);
|
||||
|
||||
if (allowedIds is not null && allowedIds.Count > 0)
|
||||
{
|
||||
query = query.Where(a => allowedIds.Contains(a.Id));
|
||||
}
|
||||
|
||||
var attachments = await query
|
||||
.OrderByDescending(a => a.UploadDate)
|
||||
.Take(4)
|
||||
.ToListAsync(cancellationToken);
|
||||
@@ -1754,7 +1771,7 @@ Candidate master CV:
|
||||
}
|
||||
|
||||
[HttpPost("{id:int}/generate-application-package")]
|
||||
public async Task<ActionResult<GenerateApplicationPackageDto>> GenerateApplicationPackage([FromRoute] int id, [FromQuery] string? mode, [FromQuery] string? coverLetterStyle, CancellationToken cancellationToken)
|
||||
public async Task<ActionResult<GenerateApplicationPackageDto>> GenerateApplicationPackage([FromRoute] int id, [FromQuery] string? mode, [FromQuery] string? coverLetterStyle, [FromQuery] string? attachmentIds, CancellationToken cancellationToken)
|
||||
{
|
||||
var job = await _db.JobApplications
|
||||
.Include(j => j.Company)
|
||||
@@ -1780,7 +1797,7 @@ Candidate master CV:
|
||||
|
||||
var packageModeInstruction = BuildPackageModeInstruction(mode);
|
||||
var coverLetterStyleInstruction = BuildCoverLetterStyleInstruction(coverLetterStyle);
|
||||
var attachmentContext = await BuildAttachmentContextAsync(id, cancellationToken);
|
||||
var attachmentContext = await BuildAttachmentContextAsync(id, cancellationToken, attachmentIds);
|
||||
|
||||
var packageContext = $@"Job title: {job.JobTitle}
|
||||
Company: {job.Company?.Name}
|
||||
|
||||
Reference in New Issue
Block a user