Tidy stale comments and duplicated helpers
Comments carried over from web_server (CVLayout.vue, messageResolver, the Spotify token code) and ones outdated by later changes (the email window now anchors on ReceivedAt, failed emails are retried) are corrected. truncateRunes had a copy in handlers and in services; there is now one, services.TruncateRunes. cleanEmailBody's regexes are compiled once, a status check that could never fire is gone, and api.js loses its unused put/patch helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
|
||||
"adam-french.co.uk/job-tracker/internal/claude"
|
||||
"adam-french.co.uk/job-tracker/internal/models"
|
||||
@@ -432,7 +433,7 @@ func (s *JobLeadService) storeLeads(ctx context.Context, src models.JobSource, j
|
||||
// snippet in place rather than losing the lead.
|
||||
if job.detailID != "" && lead.Matched && lead.State == LeadNew {
|
||||
if full, err := s.fetchReedDescription(ctx, job.detailID); err == nil && full != "" {
|
||||
lead.Description = truncateRunes(full, maxLeadRunes)
|
||||
lead.Description = TruncateRunes(full, maxLeadRunes)
|
||||
}
|
||||
}
|
||||
fresh = append(fresh, lead)
|
||||
@@ -473,7 +474,7 @@ func newLead(src models.JobSource, job fetchedJob, filter leadFilter, tracked ma
|
||||
Company: company,
|
||||
Location: strings.TrimSpace(job.Location),
|
||||
URL: strings.TrimSpace(job.URL),
|
||||
Description: truncateRunes(job.Description, maxLeadRunes),
|
||||
Description: TruncateRunes(job.Description, maxLeadRunes),
|
||||
PostedAt: job.PostedAt,
|
||||
LastSeenAt: now,
|
||||
State: LeadNew,
|
||||
@@ -686,10 +687,10 @@ func containsWord(text, word string) bool {
|
||||
}
|
||||
start := from + i
|
||||
end := start + len(word)
|
||||
before := []rune(text[:start])
|
||||
after := []rune(strings.TrimPrefix(text[end:], "s"))
|
||||
if (len(before) == 0 || !isWordRune(before[len(before)-1])) &&
|
||||
(len(after) == 0 || !isWordRune(after[0])) {
|
||||
before, _ := utf8.DecodeLastRuneInString(text[:start])
|
||||
after, _ := utf8.DecodeRuneInString(strings.TrimPrefix(text[end:], "s"))
|
||||
// RuneError is what an empty side decodes to, and is not a word rune.
|
||||
if !isWordRune(before) && !isWordRune(after) {
|
||||
return true
|
||||
}
|
||||
from = start + 1
|
||||
@@ -777,7 +778,7 @@ func (s *JobLeadService) scoreLeads(ctx context.Context, profile *models.JobSear
|
||||
}
|
||||
|
||||
func (s *JobLeadService) scoreLead(ctx context.Context, profile string, lead *models.JobLead) (LeadScore, error) {
|
||||
return s.Scorer.ScorePosting(ctx, truncateRunes(profile, maxProfileRunes),
|
||||
return s.Scorer.ScorePosting(ctx, TruncateRunes(profile, maxProfileRunes),
|
||||
lead.JobTitle, lead.Company, lead.Location, lead.Description)
|
||||
}
|
||||
|
||||
@@ -802,7 +803,7 @@ func LoadJobSearchProfile(db *gorm.DB) (*models.JobSearchProfile, error) {
|
||||
// SaveJobSearchProfile stores an edited profile, bounding the free text.
|
||||
func SaveJobSearchProfile(db *gorm.DB, profile *models.JobSearchProfile) error {
|
||||
profile.ID = jobSearchProfileID
|
||||
profile.Profile = truncateRunes(strings.TrimSpace(profile.Profile), maxProfileRunes)
|
||||
profile.Profile = TruncateRunes(strings.TrimSpace(profile.Profile), maxProfileRunes)
|
||||
profile.MinScore = min(max(profile.MinScore, 0), 100)
|
||||
return db.Save(profile).Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user