Skip to content

Commit

Permalink
Don't sent empty samples to odoo
Browse files Browse the repository at this point in the history
If the executed query doesn't return any data, we shouldn't send it to
odoo as it will only pollute the Odoo job queue.

Signed-off-by: Nicolas Bigler <[email protected]>
  • Loading branch information
TheBigLee committed Dec 29, 2023
1 parent f8eef2d commit 4fc8a72
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func runQuery(ctx context.Context, odooClient OdooClient, prom PromQuerier, args
return fmt.Errorf("expected prometheus query to return a model.Vector, got %T", res)
}

if samples.Len() == 0 {
return nil
}

var errs error
records := make([]odoo.OdooMeteredBillingRecord, 0, len(samples))
for _, sample := range samples {
Expand Down

0 comments on commit 4fc8a72

Please sign in to comment.