support some filtering
This commit is contained in:
@@ -50,7 +50,12 @@ type ReportWriter interface {
|
||||
Write(context.Context, ReportItem) error
|
||||
}
|
||||
|
||||
func BuildReport(ctx context.Context, reader RecordReader, writer ReportWriter) error {
|
||||
// Selector returns true if a record should be selected for processing, false otherwise.
|
||||
type Selector func(Record) bool
|
||||
|
||||
// BuildReport reads records from a RecordReader and, if the record passes the Selector, it is
|
||||
// processed into the report
|
||||
func BuildReport(ctx context.Context, reader RecordReader, writer ReportWriter, s Selector) error {
|
||||
buys := make(map[string]*FillerQueue)
|
||||
|
||||
for {
|
||||
@@ -66,6 +71,10 @@ func BuildReport(ctx context.Context, reader RecordReader, writer ReportWriter)
|
||||
return err
|
||||
}
|
||||
|
||||
if !s(rec) {
|
||||
continue
|
||||
}
|
||||
|
||||
buyQueue, ok := buys[rec.Symbol()]
|
||||
if !ok {
|
||||
buyQueue = new(FillerQueue)
|
||||
|
||||
Reference in New Issue
Block a user