feat(summary): send complete articles within user budget (#39)
This commit is contained in:
@ -2,12 +2,32 @@ package scraper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/tradarr/backend/internal/models"
|
||||
)
|
||||
|
||||
const (
|
||||
ContentComplete = "complete"
|
||||
ContentIncomplete = "incomplete"
|
||||
ContentUnavailable = "unavailable"
|
||||
)
|
||||
|
||||
// ContentStatus never upgrades a teaser, truncated body or unknown extraction.
|
||||
func ContentStatus(a Article) string {
|
||||
if strings.TrimSpace(a.Content) == "" || strings.TrimSpace(a.Content) == strings.TrimSpace(a.Title) {
|
||||
return ContentUnavailable
|
||||
}
|
||||
if a.ContentState == ContentComplete && !a.ContentTruncated {
|
||||
return ContentComplete
|
||||
}
|
||||
return ContentIncomplete
|
||||
}
|
||||
|
||||
type Article struct {
|
||||
ContentState string
|
||||
Source string
|
||||
Title string
|
||||
Content string
|
||||
ContentTruncated bool
|
||||
@ -22,7 +42,7 @@ type Scraper interface {
|
||||
}
|
||||
|
||||
// ArticleEnricher is an optional, transient enrichment port. Generation calls
|
||||
// it only for the bounded Bloomberg pool, never for the full collected list.
|
||||
// it only after source limits, never for the full collected list.
|
||||
type ArticleEnricher interface {
|
||||
Enrich(context.Context, []Article) ([]Article, error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user