JobList filter fix

This commit is contained in:
2025-12-08 21:28:24 +01:00
parent d2fb9b8071
commit 1f95d57717
6 changed files with 49 additions and 18 deletions

View File

@@ -36,7 +36,7 @@ public class JobsController : Controller
public async Task<IActionResult> GetAll(
[FromQuery] int start = 0,
[FromQuery] int limit = 50,
[FromQuery] JobStatus? status = null,
[FromQuery] List<JobStatus>? statuses = null,
[FromQuery] JobType? jobType = null,
[FromQuery] Guid? layerId = null)
{
@@ -54,9 +54,9 @@ public class JobsController : Controller
var query = _db.QueueJobs.AsQueryable();
if (status.HasValue)
if (statuses != null && statuses.Count > 0)
{
query = query.Where(j => j.Status == status.Value);
query = query.Where(j => statuses.Contains(j.Status));
}
if (jobType.HasValue)
@@ -71,8 +71,11 @@ public class JobsController : Controller
var totalCount = await query.CountAsync();
// Sort by: Priority ASC (0=highest), JobType, then CreatedAt DESC
var items = await query
.OrderByDescending(j => j.CreatedAt)
.OrderBy(j => j.Priority)
.ThenBy(j => j.JobType)
.ThenByDescending(j => j.CreatedAt)
.Skip(start)
.Take(limit)
.AsNoTracking()