Tidy stale comments and duplicated helpers
Test and publish / test (push) Successful in 1m6s
Test and publish / publish (push) Has been skipped

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:
2026-10-14 22:47:27 +01:00
co-authored by Claude Opus 5.5
parent f5b722d100
commit c7b60578e1
10 changed files with 54 additions and 72 deletions
+2 -12
View File
@@ -152,16 +152,6 @@ type PostingExtractor interface {
ExtractPosting(ctx context.Context, url, title, text string) (claude.JobPosting, error)
}
// truncateRunes cuts s to at most max runes, on a rune boundary so the result
// is still valid UTF-8 for Postgres and for JSON.
func truncateRunes(s string, max int) string {
runes := []rune(s)
if len(runes) <= max {
return s
}
return string(runes[:max])
}
// bindCapture decodes a size-limited JSON body, answering 400 itself when it
// cannot.
func bindCapture(ctx *gin.Context, into any) bool {
@@ -192,7 +182,7 @@ func (store *Store) JobCaptureExtract(ctx *gin.Context) {
}
posting, err := store.Extractor.ExtractPosting(ctx.Request.Context(),
truncateRunes(input.URL, 2000), truncateRunes(input.Title, 500), truncateRunes(text, maxPageRunes))
services.TruncateRunes(input.URL, 2000), services.TruncateRunes(input.Title, 500), services.TruncateRunes(text, maxPageRunes))
if err != nil {
log.Println("Job extract failed:", err)
var readErr *claude.ReadError
@@ -215,7 +205,7 @@ func (store *Store) JobCapture(ctx *gin.Context) {
if !bindCapture(ctx, &input) {
return
}
input.Description = truncateRunes(strings.TrimSpace(input.Description), maxPageRunes)
input.Description = services.TruncateRunes(strings.TrimSpace(input.Description), maxPageRunes)
app, action, err := services.UpsertJobApplication(store.DB, input, time.Now())
var invalid *services.JobInputError
@@ -140,15 +140,6 @@ func TestCaptureTokenAdminEndpoints(t *testing.T) {
}
}
func TestTruncateRunes(t *testing.T) {
if got := truncateRunes("££££", 2); got != "££" {
t.Fatalf("got %q; the cut must fall on a rune boundary", got)
}
if got := truncateRunes("short", 10); got != "short" {
t.Fatalf("got %q", got)
}
}
// fakeExtractor answers every page with posting and err, recording the
// arguments it was called with.
type fakeExtractor struct {