Additional bugfixes
This commit is contained in:
@@ -68,7 +68,6 @@ func (s *Scheduler) Start() {
|
||||
s.cron.AddFunc("0 30 3 * * *", s.jobAWAnomalyDetection)
|
||||
s.cron.AddFunc("0 0 * * * *", s.jobWWIReorder)
|
||||
s.cron.AddFunc("0 30 3 * * *", s.jobWWISupplierScores)
|
||||
s.cron.AddFunc("0 30 * * * *", s.jobWWIEvents)
|
||||
s.cron.AddFunc("0 0 4 * * *", s.jobWWIDataQuality)
|
||||
s.cron.Start()
|
||||
slog.Info("scheduler started", "jobs", len(s.cron.Entries()))
|
||||
@@ -101,7 +100,6 @@ func (s *Scheduler) TriggerWWIJob(jobName string) error {
|
||||
fns := map[string]func(){
|
||||
"reorder": s.jobWWIReorder,
|
||||
"supplier_scores": s.jobWWISupplierScores,
|
||||
"events": s.jobWWIEvents,
|
||||
"data_quality": s.jobWWIDataQuality,
|
||||
}
|
||||
fn, ok := fns[jobName]
|
||||
@@ -220,12 +218,6 @@ func (s *Scheduler) jobAWDataQuality() {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
persistence.AppendAudit(ctx, s.pgPool, persistence.AuditEntry{
|
||||
Action: "job.completed", ActorType: "scheduler", ActorID: "aw.daily.data_quality",
|
||||
Domain: "aw", Service: "otel-bi-analytics", EntityType: "data_quality",
|
||||
Status: report.Status,
|
||||
Payload: map[string]any{"status": report.Status, "failed_checks": report.FailedChecks},
|
||||
})
|
||||
return len(report.Checks), nil
|
||||
})
|
||||
}
|
||||
@@ -270,37 +262,12 @@ func (s *Scheduler) jobWWISupplierScores() {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Scheduler) jobWWIEvents() {
|
||||
s.runJob("wwi.hourly.events", "wwi", func(ctx context.Context) (int, error) {
|
||||
data, err := analytics.WWIGetReorderRecommendations(ctx, s.wwiDB)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var highUrgency []analytics.ReorderRecommendation
|
||||
for _, item := range data {
|
||||
if item.Urgency == "HIGH" {
|
||||
highUrgency = append(highUrgency, item)
|
||||
}
|
||||
}
|
||||
if err := persistence.GenerateStockEvents(ctx, s.pgPool, highUrgency); err != nil {
|
||||
slog.Warn("generate_stock_events (events job) failed", "err", err)
|
||||
}
|
||||
return len(highUrgency), nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Scheduler) jobWWIDataQuality() {
|
||||
s.runJob("wwi.daily.data_quality", "wwi", func(ctx context.Context) (int, error) {
|
||||
report, err := analytics.WWIRunDataQualityCheck(ctx, s.wwiDB)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
persistence.AppendAudit(ctx, s.pgPool, persistence.AuditEntry{
|
||||
Action: "job.completed", ActorType: "scheduler", ActorID: "wwi.daily.data_quality",
|
||||
Domain: "wwi", Service: "otel-bi-analytics", EntityType: "data_quality",
|
||||
Status: report.Status,
|
||||
Payload: map[string]any{"status": report.Status, "failed_checks": report.FailedChecks},
|
||||
})
|
||||
return len(report.Checks), nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user