Add genetic backtest to worker
This commit is contained in:
@@ -816,7 +816,7 @@ public class BacktestController : BaseController
|
||||
|
||||
// Get all jobs for this bundle
|
||||
using var serviceScope = _serviceScopeFactory.CreateScope();
|
||||
var jobRepository = serviceScope.ServiceProvider.GetRequiredService<IBacktestJobRepository>();
|
||||
var jobRepository = serviceScope.ServiceProvider.GetRequiredService<IJobRepository>();
|
||||
var jobs = await jobRepository.GetByBundleRequestIdAsync(bundleGuid);
|
||||
|
||||
var response = new BundleBacktestStatusResponse
|
||||
@@ -824,10 +824,10 @@ public class BacktestController : BaseController
|
||||
BundleRequestId = bundleGuid,
|
||||
Status = bundleRequest.Status.ToString(),
|
||||
TotalJobs = jobs.Count(),
|
||||
CompletedJobs = jobs.Count(j => j.Status == BacktestJobStatus.Completed),
|
||||
FailedJobs = jobs.Count(j => j.Status == BacktestJobStatus.Failed),
|
||||
RunningJobs = jobs.Count(j => j.Status == BacktestJobStatus.Running),
|
||||
PendingJobs = jobs.Count(j => j.Status == BacktestJobStatus.Pending),
|
||||
CompletedJobs = jobs.Count(j => j.Status == JobStatus.Completed),
|
||||
FailedJobs = jobs.Count(j => j.Status == JobStatus.Failed),
|
||||
RunningJobs = jobs.Count(j => j.Status == JobStatus.Running),
|
||||
PendingJobs = jobs.Count(j => j.Status == JobStatus.Pending),
|
||||
ProgressPercentage = bundleRequest.ProgressPercentage,
|
||||
CreatedAt = bundleRequest.CreatedAt,
|
||||
CompletedAt = bundleRequest.CompletedAt,
|
||||
|
||||
@@ -68,7 +68,7 @@ public class JobController : BaseController
|
||||
/// <param name="jobId">The job ID to query</param>
|
||||
/// <returns>The job status and result if completed</returns>
|
||||
[HttpGet("{jobId}")]
|
||||
public async Task<ActionResult<BacktestJobStatusResponse>> GetJobStatus(string jobId)
|
||||
public async Task<ActionResult<JobStatusResponse>> GetJobStatus(string jobId)
|
||||
{
|
||||
if (!await IsUserAdmin())
|
||||
{
|
||||
@@ -82,7 +82,7 @@ public class JobController : BaseController
|
||||
}
|
||||
|
||||
using var serviceScope = _serviceScopeFactory.CreateScope();
|
||||
var jobRepository = serviceScope.ServiceProvider.GetRequiredService<IBacktestJobRepository>();
|
||||
var jobRepository = serviceScope.ServiceProvider.GetRequiredService<IJobRepository>();
|
||||
var job = await jobRepository.GetByIdAsync(jobGuid);
|
||||
|
||||
if (job == null)
|
||||
@@ -90,7 +90,7 @@ public class JobController : BaseController
|
||||
return NotFound($"Job with ID {jobId} not found.");
|
||||
}
|
||||
|
||||
var response = new BacktestJobStatusResponse
|
||||
var response = new JobStatusResponse
|
||||
{
|
||||
JobId = job.Id,
|
||||
Status = job.Status.ToString(),
|
||||
@@ -99,7 +99,7 @@ public class JobController : BaseController
|
||||
StartedAt = job.StartedAt,
|
||||
CompletedAt = job.CompletedAt,
|
||||
ErrorMessage = job.ErrorMessage,
|
||||
Result = job.Status == BacktestJobStatus.Completed && !string.IsNullOrEmpty(job.ResultJson)
|
||||
Result = job.Status == JobStatus.Completed && !string.IsNullOrEmpty(job.ResultJson)
|
||||
? JsonSerializer.Deserialize<LightBacktest>(job.ResultJson)
|
||||
: null
|
||||
};
|
||||
@@ -156,16 +156,16 @@ public class JobController : BaseController
|
||||
}
|
||||
|
||||
// Parse status filter
|
||||
BacktestJobStatus? statusFilter = null;
|
||||
JobStatus? statusFilter = null;
|
||||
if (!string.IsNullOrEmpty(status))
|
||||
{
|
||||
if (Enum.TryParse<BacktestJobStatus>(status, true, out var parsedStatus))
|
||||
if (Enum.TryParse<JobStatus>(status, true, out var parsedStatus))
|
||||
{
|
||||
statusFilter = parsedStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest($"Invalid status value. Valid values are: {string.Join(", ", Enum.GetNames<BacktestJobStatus>())}");
|
||||
return BadRequest($"Invalid status value. Valid values are: {string.Join(", ", Enum.GetNames<JobStatus>())}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ public class JobController : BaseController
|
||||
}
|
||||
|
||||
using var serviceScope = _serviceScopeFactory.CreateScope();
|
||||
var jobRepository = serviceScope.ServiceProvider.GetRequiredService<IBacktestJobRepository>();
|
||||
var jobRepository = serviceScope.ServiceProvider.GetRequiredService<IJobRepository>();
|
||||
|
||||
var (jobs, totalCount) = await jobRepository.GetPaginatedAsync(
|
||||
page,
|
||||
@@ -257,7 +257,7 @@ public class JobController : BaseController
|
||||
}
|
||||
|
||||
using var serviceScope = _serviceScopeFactory.CreateScope();
|
||||
var jobRepository = serviceScope.ServiceProvider.GetRequiredService<IBacktestJobRepository>();
|
||||
var jobRepository = serviceScope.ServiceProvider.GetRequiredService<IJobRepository>();
|
||||
|
||||
var summary = await jobRepository.GetSummaryAsync();
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ using Managing.Domain.Backtests;
|
||||
namespace Managing.Api.Models.Responses;
|
||||
|
||||
/// <summary>
|
||||
/// Response model for backtest job status
|
||||
/// Response model for job status
|
||||
/// </summary>
|
||||
public class BacktestJobStatusResponse
|
||||
public class JobStatusResponse
|
||||
{
|
||||
public Guid JobId { get; set; }
|
||||
public string Status { get; set; } = string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user