feat(discovery): auto-trigger Pass A enrichment after crawl
This commit is contained in:
@@ -293,6 +293,21 @@ func (s *Service) Crawl(ctx context.Context) (CrawlSummary, error) {
|
||||
}
|
||||
summary.Discovered++
|
||||
}
|
||||
|
||||
// Automatically kick off Pass A enrichment (CrawlEnrich + Nominatim) for
|
||||
// all newly-inserted rows so manual triggers are not needed for fresh crawls.
|
||||
// 45 minutes matches the handler's enrichAllTimeout — gives the geocoder
|
||||
// enough headroom even for large batches.
|
||||
if summary.Discovered > 0 {
|
||||
go func() {
|
||||
enrichCtx, cancel := context.WithTimeout(context.Background(), 45*time.Minute)
|
||||
defer cancel()
|
||||
if _, err := s.RunCrawlEnrichAll(enrichCtx); err != nil && !errors.Is(err, context.DeadlineExceeded) {
|
||||
slog.WarnContext(context.Background(), "post-crawl enrichment failed", "error", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
summary.DurationMs = time.Since(summary.StartedAt).Milliseconds()
|
||||
slog.InfoContext(ctx, "crawl completed",
|
||||
"duration_ms", summary.DurationMs,
|
||||
|
||||
Reference in New Issue
Block a user