From 4fc8a7299d057a8ee16728c492ef67ae3e23be50 Mon Sep 17 00:00:00 2001 From: Nicolas Bigler Date: Fri, 29 Dec 2023 10:40:37 +0100 Subject: [PATCH] Don't sent empty samples to odoo 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 --- pkg/report/report.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/report/report.go b/pkg/report/report.go index 2442068..31a1d99 100644 --- a/pkg/report/report.go +++ b/pkg/report/report.go @@ -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 {