fix: Add HistoricalBatchShadowRunJob to DI and fix ExecuteAsync signature
- Register HistoricalBatchShadowRunJob in services (line 106) - Simplified ExecuteAsync to take only CancellationToken (Hangfire lambda requirement) - Set targetModelId to Guid.Empty for batch processing Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,10 +36,10 @@ public sealed class HistoricalBatchShadowRunJob(
|
||||
/// </summary>
|
||||
[Queue("q-research")]
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 300)] // 5 min to queue; job itself has 30 min
|
||||
public async Task ExecuteAsync(Guid? modelId = null, CancellationToken cancellationToken = default)
|
||||
public async Task ExecuteAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
// Use provided modelId or default to all-models sentinel
|
||||
var targetModelId = modelId ?? Guid.Empty;
|
||||
// Use all-models sentinel for batch
|
||||
var targetModelId = Guid.Empty;
|
||||
|
||||
// Calculate 1-year window: 252 trading days ≈ 365 calendar days
|
||||
var endDate = DateOnly.FromDateTime(clock.UtcNow.Date);
|
||||
|
||||
@@ -103,6 +103,7 @@ builder.Services.AddScoped<RecommendationReportGenerator>();
|
||||
builder.Services.AddScoped<GenerateDailyRecommendationJob>();
|
||||
builder.Services.AddScoped<GenerateWeeklyRecommendationJob>();
|
||||
builder.Services.AddScoped<GenerateMonthlyRecommendationJob>();
|
||||
builder.Services.AddScoped<HistoricalBatchShadowRunJob>();
|
||||
|
||||
// OpenDart Services
|
||||
builder.Services.AddScoped<OpenDartService>();
|
||||
@@ -395,7 +396,7 @@ else
|
||||
|
||||
// Register other Hangfire jobs
|
||||
var kstTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Asia/Seoul");
|
||||
try { RecurringJob.AddOrUpdate<HistoricalBatchShadowRunJob>("historical-batch-shadow-run", job => job.ExecuteAsync(null, CancellationToken.None), "0 21 * * *", new RecurringJobOptions { TimeZone = kstTimeZone }); logger.LogInformation("✅ historical-batch-shadow-run registered (daily 21:00 KST)"); } catch (Exception ex) { logger.LogWarning(ex, "⚠️ historical-batch-shadow-run error"); }
|
||||
try { RecurringJob.AddOrUpdate<HistoricalBatchShadowRunJob>("historical-batch-shadow-run", job => job.ExecuteAsync(CancellationToken.None), "0 21 * * *", new RecurringJobOptions { TimeZone = kstTimeZone }); logger.LogInformation("✅ historical-batch-shadow-run registered (daily 21:00 KST)"); } catch (Exception ex) { logger.LogWarning(ex, "⚠️ historical-batch-shadow-run error"); }
|
||||
try { RecurringJob.AddOrUpdate<OpenDartDailyBatchJob>("opendart-daily-batch", job => job.ExecuteAsync(CancellationToken.None), "0 9 * * *", new RecurringJobOptions { TimeZone = kstTimeZone }); logger.LogInformation("✅ opendart-daily-batch registered"); } catch (Exception ex) { logger.LogWarning(ex, "⚠️ opendart-daily-batch error"); }
|
||||
try { RecurringJob.AddOrUpdate<GenerateDailyRecommendationJob>("daily-recommendation", job => job.ExecuteAsync(CancellationToken.None), "0 9 * * *", new RecurringJobOptions { TimeZone = kstTimeZone }); logger.LogInformation("✅ daily-recommendation registered"); } catch (Exception ex) { logger.LogWarning(ex, "⚠️ daily-recommendation error"); }
|
||||
try { RecurringJob.AddOrUpdate<GenerateWeeklyRecommendationJob>("weekly-recommendation", job => job.ExecuteAsync(CancellationToken.None), "0 9 * * 6", new RecurringJobOptions { TimeZone = kstTimeZone }); logger.LogInformation("✅ weekly-recommendation registered"); } catch (Exception ex) { logger.LogWarning(ex, "⚠️ weekly-recommendation error"); }
|
||||
|
||||
Reference in New Issue
Block a user