feat: scan only posts jobs at or above a minimum fit score

This commit is contained in:
2026-11-25 09:40:51 +01:00
parent f7dcbb9c14
commit 2218eb273b
4 changed files with 61 additions and 15 deletions
+16 -3
View File
@@ -16,7 +16,8 @@ import (
// Scanner is the scheduled half: it reads the company feeds, keeps the jobs
// that match the search profile and have not been seen before, and runs each
// through the same assessment the bot uses. Postings that require a language
// the CV does not list are dropped silently.
// the CV does not list, or that score below the minimum fit, get no note and
// no package: they only show up in the one-line summary of the run.
type Scanner struct {
cfg Config
sources []Source
@@ -129,6 +130,7 @@ func (s *Scanner) run(ctx context.Context) error {
jobs, failedFeeds := s.candidates(ctx, seen)
var posted, dropped int
var lowFit []string
var stopped error
done := 0
for _, j := range jobs {
@@ -144,6 +146,9 @@ func (s *Scanner) run(ctx context.Context) error {
break
}
done++
if fit, ok := strings.CutPrefix(outcome, "low fit "); ok {
lowFit = append(lowFit, fmt.Sprintf("%s, %s (%s)", j.Company, j.Title, fit))
}
seen[j.Key] = s.now().Format(time.DateOnly) + " " + outcome
if err := s.saveSeen(seen); err != nil {
return fmt.Errorf("saving seen jobs: %w", err) // or the next run posts duplicates
@@ -156,11 +161,16 @@ func (s *Scanner) run(ctx context.Context) error {
}
}
slog.Info("scan finished", "matches", len(jobs), "posted", posted, "dropped_language", dropped, "queued", len(jobs)-done)
slog.Info("scan finished", "matches", len(jobs), "posted", posted, "dropped_language", dropped,
"dropped_low_fit", len(lowFit), "queued", len(jobs)-done)
if done == 0 && stopped == nil && len(failedFeeds) == 0 {
return nil // nothing new: stay quiet
}
line := fmt.Sprintf("Scan: %d posted, %d dropped for a language requirement, %d still queued.", posted, dropped, len(jobs)-done)
line := fmt.Sprintf("Scan: %d posted, %d dropped for a language requirement, %d below fit %d, %d still queued.",
posted, dropped, len(lowFit), s.cfg.ScanMinFit, len(jobs)-done)
if len(lowFit) > 0 {
line += "\nBelow the cutoff: " + strings.Join(lowFit, "; ") + "."
}
if len(failedFeeds) > 0 {
line += " Feeds that failed: " + strings.Join(failedFeeds, ", ") + "."
}
@@ -198,6 +208,9 @@ func (s *Scanner) handle(ctx context.Context, j Job) (string, error) {
case pkg.LanguageBlocker:
slog.Info("dropped: language requirement", "company", j.Company, "title", j.Title, "why", pkg.DutchRequirement)
return "language", nil
case pkg.FitScore < s.cfg.ScanMinFit:
slog.Info("dropped: low fit", "company", j.Company, "title", j.Title, "fit", pkg.FitScore, "why", pkg.VerdictReason)
return fmt.Sprintf("low fit %d", pkg.FitScore), nil
}
note := renderNote(pkg, j.URL, s.now())