From b729e7d0960bf16caa7f7fcf05678ba2367e419e Mon Sep 17 00:00:00 2001 From: Omar Abdulaziz Date: Tue, 17 Sep 2024 16:41:52 +0300 Subject: [PATCH] early return when a twin does not have contracts --- grid-proxy/internal/explorer/db_client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grid-proxy/internal/explorer/db_client.go b/grid-proxy/internal/explorer/db_client.go index 1434b7d9..560570dc 100644 --- a/grid-proxy/internal/explorer/db_client.go +++ b/grid-proxy/internal/explorer/db_client.go @@ -152,6 +152,10 @@ func (c *DBClient) GetTwinConsumption(ctx context.Context, twinId uint64) (types } } + if len(allCIds) == 0 { + return types.TwinConsumption{}, nil + } + // get the latest two reports for each active contract reports, err := c.DB.GetContractsLatestBillReports(ctx, nonDeletedCIds, 2) if err != nil {