fix: counting of performed update
All checks were successful
CI / test (pull_request) Successful in 2m34s

This commit is contained in:
2024-12-29 17:10:25 +01:00
parent 8e3f1e893b
commit 16921d41f3

View File

@@ -73,7 +73,7 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
var wg sync.WaitGroup
numberUpdated := make(chan int)
numberUpdatedChannel := make(chan int)
for _, domain := range c.domains {
for _, subdomain := range domain.Subdomains {
@@ -131,7 +131,7 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
return
}
numberUpdated <- 1
numberUpdatedChannel <- 1
}
}(domain, subdomain)
}
@@ -139,9 +139,14 @@ func (c *ChangeDetector) detectAndApplyChanges() (int, error) {
go func() {
wg.Wait()
close(numberUpdated)
close(numberUpdatedChannel)
}()
c.logger.Info("Run completed", slog.Int("number_of_changes", <-numberUpdated))
return <-numberUpdated, nil
numberUpdated := 0
for v := range numberUpdatedChannel {
numberUpdated += v
}
c.logger.Info("Run completed", slog.Int("number_of_changes", numberUpdated))
return numberUpdated, nil
}