feat: externalize filter configuration and add global structured logging and job reprocessing functionality
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package filter
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hireme/hireme/internal/db"
|
||||
)
|
||||
|
||||
type FilterResult struct {
|
||||
Keep bool
|
||||
@@ -10,7 +14,7 @@ type FilterResult struct {
|
||||
|
||||
type JobFilter interface {
|
||||
Name() string
|
||||
Process(ctx context.Context, title, rawContent string) (FilterResult, error)
|
||||
Process(ctx context.Context, job *db.RawJob) (FilterResult, error)
|
||||
}
|
||||
|
||||
type FilterPipeline struct {
|
||||
@@ -21,10 +25,10 @@ func NewPipeline(filters ...JobFilter) *FilterPipeline {
|
||||
return &FilterPipeline{filters: filters}
|
||||
}
|
||||
|
||||
func (p *FilterPipeline) Execute(ctx context.Context, title, rawContent string) (bool, float64, string) {
|
||||
func (p *FilterPipeline) Execute(ctx context.Context, job *db.RawJob) (bool, float64, string) {
|
||||
var totalScore float64
|
||||
for _, f := range p.filters {
|
||||
res, err := f.Process(ctx, title, rawContent)
|
||||
res, err := f.Process(ctx, job)
|
||||
if err != nil {
|
||||
return false, 0, err.Error()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user