fix(discovery): restore SQLite saved-search listing
This commit is contained in:
@@ -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")]
|
||||
|
||||
Reference in New Issue
Block a user