fix(discovery): restore SQLite saved-search listing

This commit is contained in:
cesnimda
2026-10-09 14:44:36 +02:00
parent 54a377054f
commit bcc9599049
2 changed files with 238 additions and 3 deletions
@@ -51,9 +51,18 @@ public sealed class JobDiscoveryController : ControllerBase
public async Task<ActionResult<IReadOnlyList<SavedSearchDto>>> ListSavedSearches(CancellationToken cancellationToken)
{
if (!TryGetPersistence(out var db, out var owner)) return Unauthorized();
var searches = await db.SavedJobSearches.AsNoTracking().Include(x => x.Results)
.Where(x => x.OwnerUserId == owner).OrderByDescending(x => x.UpdatedAtUtc).ToListAsync(cancellationToken);
return Ok(searches.Select(ToDto).ToList());
var query = db.SavedJobSearches.AsNoTracking().Where(x => x.OwnerUserId == owner)
.Select(x => new
{
x.UpdatedAtUtc,
Summary = new SavedSearchDto(x.Id, x.Name, x.Query, x.Location, x.IsActive, x.LastRunAtUtc,
x.Results.Count, x.Results.Count(result => result.IsDismissed))
});
// SQLite cannot order DateTimeOffset; sort owned summaries after SQL filtering/counts.
var searches = db.Database.IsSqlite()
? (await query.ToListAsync(cancellationToken)).OrderByDescending(x => x.UpdatedAtUtc).ToList()
: await query.OrderByDescending(x => x.UpdatedAtUtc).ToListAsync(cancellationToken);
return Ok(searches.Select(x => x.Summary).ToList());
}
[HttpPost("saved-searches")]