simplify output and stop on invalid kind
This commit is contained in:
+8
-12
@@ -98,10 +98,11 @@ func BuildReport(ctx context.Context, reader RecordReader, writer ReportWriter,
|
||||
return fmt.Errorf("loading state: %w", err)
|
||||
}
|
||||
|
||||
var buysCount, sellsCount int64
|
||||
var lastTimestamp time.Time
|
||||
progTicker := time.NewTicker(10 * time.Second)
|
||||
|
||||
var (
|
||||
recordsCount int64
|
||||
lastTimestamp time.Time
|
||||
progTicker = time.NewTicker(10 * time.Second)
|
||||
)
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
@@ -109,9 +110,7 @@ func BuildReport(ctx context.Context, reader RecordReader, writer ReportWriter,
|
||||
case <-progTicker.C:
|
||||
slog.InfoContext(
|
||||
ctx, "Progress update",
|
||||
slog.Int64("total_records", buysCount+sellsCount),
|
||||
slog.Int64("sell_records", sellsCount),
|
||||
slog.Int64("buy_records", buysCount),
|
||||
slog.Int64("records_count", recordsCount),
|
||||
slog.Time("last_record_timestamp", lastTimestamp),
|
||||
)
|
||||
default:
|
||||
@@ -128,15 +127,12 @@ func BuildReport(ctx context.Context, reader RecordReader, writer ReportWriter,
|
||||
return err
|
||||
}
|
||||
|
||||
if rec.Kind().Is(KindBuy) {
|
||||
buysCount++
|
||||
} else if rec.Kind().Is(KindSell) {
|
||||
sellsCount++
|
||||
} else if !rec.Kind().Valid() {
|
||||
if !rec.Kind().Valid() {
|
||||
return fmt.Errorf("cannot process Kind(%d)", rec.Kind())
|
||||
}
|
||||
|
||||
lastTimestamp = rec.Timestamp()
|
||||
recordsCount++
|
||||
|
||||
buyQueue, ok := buys[rec.Symbol()]
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user