fix #5194 - improve performance of retrieving scheduled job logs

This commit is contained in:
sbwalker
2025-03-31 13:16:35 -04:00
parent 72da77be01
commit e6ba2cce62
8 changed files with 24 additions and 18 deletions

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Oqtane.Models;
@ -15,9 +15,17 @@ namespace Oqtane.Repository
}
public IEnumerable<JobLog> GetJobLogs()
{
return GetJobLogs(-1);
}
public IEnumerable<JobLog> GetJobLogs(int jobId)
{
return _db.JobLog
.AsNoTracking()
.Where(item => item.JobId == jobId || jobId == -1)
.Include(item => item.Job) // eager load jobs
.OrderByDescending(item => item.JobLogId)
.ToList();
}