- Updated comments and logging messages in the worker and related files to replace "daily-run" with "auto run" for clarity and consistency. - Adjusted the `WorkerConfig` struct to reflect the new terminology in configuration settings. - Renamed functions and test cases to align with the updated terminology, enhancing code readability and maintainability. This change improves the clarity of the AI pipeline's functionality within the tender management system.
This commit is contained in:
@@ -23,7 +23,7 @@ import (
|
||||
"tm/pkg/schedule"
|
||||
)
|
||||
|
||||
// aiPipelineDailyRunMu ensures only one AI pipeline daily-run executes at a time (startup catch-up and cron).
|
||||
// aiPipelineDailyRunMu ensures only one AI pipeline auto run executes at a time (startup catch-up and cron).
|
||||
var aiPipelineDailyRunMu sync.Mutex
|
||||
|
||||
// Init Application Configuration
|
||||
@@ -98,8 +98,8 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
"translation_enabled": config.Worker.TranslationEnabled,
|
||||
"translation_interval": config.Worker.TranslationInterval,
|
||||
"notification_interval": config.Worker.NotificationInterval,
|
||||
"ai_pipeline_daily_enabled": config.Worker.AIPipelineAutoEnabled,
|
||||
"ai_pipeline_daily_interval": config.Worker.AIPipelineAutoInterval,
|
||||
"ai_pipeline_auto_enabled": config.Worker.AIPipelineAutoEnabled,
|
||||
"ai_pipeline_auto_interval": config.Worker.AIPipelineAutoInterval,
|
||||
})
|
||||
// Initialize repositories
|
||||
noticeRepo := notice.NewRepository(mongoManager, appLogger)
|
||||
@@ -231,8 +231,8 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
})
|
||||
|
||||
if !config.Worker.AIPipelineAutoEnabled {
|
||||
appLogger.Info("AI pipeline daily-run worker disabled by configuration", map[string]interface{}{
|
||||
"ai_pipeline_daily_enabled": false,
|
||||
appLogger.Info("AI pipeline auto worker disabled by configuration", map[string]interface{}{
|
||||
"ai_pipeline_auto_enabled": false,
|
||||
})
|
||||
} else if aiClient != nil {
|
||||
dailyJobTracker := schedule.NewDailyJobTracker(mongoManager, appLogger)
|
||||
@@ -246,13 +246,13 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
|
||||
completed, checkErr := dailyJobTracker.IsCompleted(ctx, schedule.AIPipelineDailyJobName, today)
|
||||
if checkErr != nil {
|
||||
appLogger.Error("Failed to check AI pipeline daily-run completion status", map[string]interface{}{
|
||||
appLogger.Error("Failed to check AI pipeline auto completion status", map[string]interface{}{
|
||||
"trigger": trigger,
|
||||
"error": checkErr.Error(),
|
||||
"date": today.Format("02/01/2006"),
|
||||
})
|
||||
} else if completed {
|
||||
appLogger.Info("AI pipeline daily-run skipped: already completed today", map[string]interface{}{
|
||||
appLogger.Info("AI pipeline auto skipped: already completed today", map[string]interface{}{
|
||||
"trigger": trigger,
|
||||
"date": today.Format("02/01/2006"),
|
||||
})
|
||||
@@ -260,11 +260,11 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
}
|
||||
|
||||
if trigger == "startup" {
|
||||
appLogger.Info("Running startup catch-up for today's AI pipeline daily-run", map[string]interface{}{
|
||||
appLogger.Info("Running startup catch-up for today's AI pipeline auto run", map[string]interface{}{
|
||||
"date": today.Format("02/01/2006"),
|
||||
})
|
||||
} else {
|
||||
appLogger.Info("Running scheduled AI pipeline daily-run", map[string]interface{}{
|
||||
appLogger.Info("Running scheduled AI pipeline auto run", map[string]interface{}{
|
||||
"date": today.Format("02/01/2006"),
|
||||
})
|
||||
}
|
||||
@@ -272,12 +272,12 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
worker := workers.NewAIPipelineDailyWorker(appLogger, aiClient)
|
||||
if err := worker.Run(); err != nil {
|
||||
if errors.Is(err, ai_summarizer.ErrPipelineJobRunning) {
|
||||
appLogger.Info("AI pipeline daily-run deferred: job already running", map[string]interface{}{
|
||||
appLogger.Info("AI pipeline auto deferred: job already running", map[string]interface{}{
|
||||
"trigger": trigger,
|
||||
"date": today.Format("02/01/2006"),
|
||||
})
|
||||
} else {
|
||||
appLogger.Error("AI pipeline daily-run failed", map[string]interface{}{
|
||||
appLogger.Error("AI pipeline auto failed", map[string]interface{}{
|
||||
"trigger": trigger,
|
||||
"date": today.Format("02/01/2006"),
|
||||
"error": err.Error(),
|
||||
@@ -287,14 +287,14 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
}
|
||||
|
||||
if markErr := dailyJobTracker.MarkCompleted(ctx, schedule.AIPipelineDailyJobName, today); markErr != nil {
|
||||
appLogger.Error("Failed to mark AI pipeline daily-run as completed", map[string]interface{}{
|
||||
appLogger.Error("Failed to mark AI pipeline auto as completed", map[string]interface{}{
|
||||
"trigger": trigger,
|
||||
"date": today.Format("02/01/2006"),
|
||||
"error": markErr.Error(),
|
||||
})
|
||||
}
|
||||
|
||||
appLogger.Info("AI pipeline daily-run completed successfully", map[string]interface{}{
|
||||
appLogger.Info("AI pipeline auto completed successfully", map[string]interface{}{
|
||||
"trigger": trigger,
|
||||
"date": today.Format("02/01/2006"),
|
||||
})
|
||||
@@ -305,11 +305,11 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
}
|
||||
|
||||
scheduler.AddJob(schedule.Job{
|
||||
Name: "AI Pipeline Daily Run Job",
|
||||
Name: "AI Pipeline Auto Job",
|
||||
Func: func() { runAIPipelineDaily("scheduled") },
|
||||
Expr: config.Worker.AIPipelineAutoInterval,
|
||||
})
|
||||
appLogger.Info("Scheduled AI pipeline daily-run worker", map[string]interface{}{
|
||||
appLogger.Info("Scheduled AI pipeline auto worker", map[string]interface{}{
|
||||
"interval": config.Worker.AIPipelineAutoInterval,
|
||||
})
|
||||
|
||||
@@ -317,7 +317,7 @@ func InitWorker(config Config, mongoManager *mongo.ConnectionManager, appLogger
|
||||
runAIPipelineDaily("startup")
|
||||
}()
|
||||
} else {
|
||||
appLogger.Warn("AI summarizer client not available, AI pipeline daily-run worker is disabled", map[string]interface{}{})
|
||||
appLogger.Warn("AI summarizer client not available, AI pipeline auto worker is disabled", map[string]interface{}{})
|
||||
}
|
||||
|
||||
// After a server restart, process any unprocessed notices (including today's) without blocking startup.
|
||||
|
||||
Reference in New Issue
Block a user