Files
eleith dd82382bed feat: implement Phases 2, 3, and 4 (Filter Engine, Processor Refactor, LLM Categories)
This commit delivers the core logic for the Multi-Digest Architecture.

Phase 2 (Filter Engine):
- Implemented 'internal/filter' with exact/prefix/regex matching.
- Implemented 'internal/manager' for digest priority assignment.
- Updated 'models.Entry' to include 'SiteURL'.

Phase 3 (Processor Refactor):
- Updated 'ProcessDigest' to filter entries using 'DigestManager'.
- Updated 'main.go' to schedule jobs per digest index.

Phase 4 (LLM & Categorization):
- Added 'DefaultCategories' in 'internal/config'.
- Updated LLM prompts and service flow to respect user-defined or default categories.
- Updated mocks and tests across the board.

The application now supports configuring multiple digests with distinct filters and categories, and correctly assigns entries and prompts the LLM accordingly.
2025-12-16 11:00:38 -08:00

40 lines
863 B
Go

package manager
import (
"miniflux-digest/internal/config"
"miniflux-digest/internal/filter"
"miniflux-digest/internal/models"
)
type DigestManager struct {
digests []config.ConfigDigest
matchers []*filter.Matcher
}
func NewDigestManager(digests []config.ConfigDigest) (*DigestManager, error) {
matchers := make([]*filter.Matcher, len(digests))
for i, d := range digests {
m, err := filter.NewMatcher(d.Filters)
if err != nil {
return nil, err
}
matchers[i] = m
}
return &DigestManager{
digests: digests,
matchers: matchers,
}, nil
}
// GetOwningDigest returns the index of the first digest that matches the entry.
// Returns -1 if no digest matches.
func (dm *DigestManager) GetOwningDigest(entry *models.Entry) int {
for i, m := range dm.matchers {
if m.Matches(entry, dm.digests[i].Filters) {
return i
}
}
return -1
}