From ccc1e005d800a5d34299958a76d5c16a17649329 Mon Sep 17 00:00:00 2001 From: Martin Bruse Date: Fri, 19 Apr 2024 08:34:17 +0000 Subject: [PATCH] Made progress.Bar.Update and the worker pool OnComplete func use the same signature. --- go/dataset/runner/runner.go | 6 +++--- go/progress/bar.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go/dataset/runner/runner.go b/go/dataset/runner/runner.go index de64c7b..041aa97 100644 --- a/go/dataset/runner/runner.go +++ b/go/dataset/runner/runner.go @@ -161,7 +161,7 @@ func (s Setup) getOptimizeComparisons() (map[string]comparisonSlice, error) { pool := &worker.Pool[prepareResult]{ Workers: safeInt(s.MaxWorkers), OnComplete: func(submitted, completed int) { - bar.Update(completed, submitted) + bar.Update(submitted, completed) }, } for _, loopDatasetDir := range datasetDirs { @@ -256,7 +256,7 @@ func (s Setup) optimize() error { pool := &worker.Pool[compareResult]{ Workers: safeInt(s.MaxWorkers), OnComplete: func(submitted, completed int) { - bar.Update(completed, submitted) + bar.Update(submitted, completed) }, } @@ -462,7 +462,7 @@ func (s Setup) Run() error { } bar := progress.New(fmt.Sprintf("Calculating for %v references", len(data.References))) result, err := data.Calculate(metrics, func(submitted, completed int) { - bar.Update(completed, submitted) + bar.Update(submitted, completed) }, safeInt(s.MaxWorkers), safeString(s.ProgressDirectory)) if err != nil { return err diff --git a/go/progress/bar.go b/go/progress/bar.go index c7af82c..9ffc5ce 100644 --- a/go/progress/bar.go +++ b/go/progress/bar.go @@ -63,11 +63,11 @@ type Bar struct { // AddCompleted adds completed tasks to the bar and renders it. func (b *Bar) AddCompleted(num int) { - b.Update(b.completed+num, b.total) + b.Update(b.total, b.completed+num) } // Update update completed and total tasks to the bar and updates it. -func (b *Bar) Update(completed, total int) { +func (b *Bar) Update(total, completed int) { prefix := fmt.Sprintf("%s, %d/%d ", b.name, completed, total) now := time.Now()