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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user