From 16454fedb0cc9c7970f2aad11a9dcfc7c375aca1 Mon Sep 17 00:00:00 2001 From: Jonathan Rios Date: Wed, 16 Oct 2024 15:53:36 +0200 Subject: [PATCH] LITE-31021 Billing request report filter by date range was not working --- reports/billing_requests/entrypoint.py | 4 ++-- tests/test_billing_requests.py | 24 ++++++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/reports/billing_requests/entrypoint.py b/reports/billing_requests/entrypoint.py index 7423b3c..c116221 100644 --- a/reports/billing_requests/entrypoint.py +++ b/reports/billing_requests/entrypoint.py @@ -53,8 +53,8 @@ def generate( def _get_requests(client, parameters): query = R() - query &= R().created.ge(parameters['date']['after']) - query &= R().created.le(parameters['date']['before']) + query &= R().events.created.at.ge(parameters['date']['after']) + query &= R().events.created.at.le(parameters['date']['before']) if parameters.get('product') and parameters['product']['all'] is False: query &= R().asset.product.id.oneof(parameters['product']['choices']) diff --git a/tests/test_billing_requests.py b/tests/test_billing_requests.py index 8db0553..2b32fd4 100644 --- a/tests/test_billing_requests.py +++ b/tests/test_billing_requests.py @@ -39,7 +39,10 @@ def test_generate(progress, client_factory, response_factory, billing_request): responses.append( response_factory( - query='and(ge(created,2020-12-01T00:00:00),le(created,2021-01-01T00:00:00))', + query=( + 'and(ge(events.created.at,2020-12-01T00:00:00),' + 'le(events.created.at,2021-01-01T00:00:00))' + ), value=[billing_request], ), ) @@ -86,9 +89,12 @@ def test_generate_additional(progress, client_factory, response_factory, billing responses.append( response_factory( - query='and(ge(created,2020-12-01T00:00:00),le(created,2021-01-01T00:00:00),' - 'in(asset.product.id,(PRD-276-377-545)),in(asset.marketplace.id,(MP-123)),' - 'in(asset.connection.hub.id,(HB-123)))', + query=( + 'and(ge(events.created.at,2020-12-01T00:00:00),' + 'le(events.created.at,2021-01-01T00:00:00),' + 'in(asset.product.id,(PRD-276-377-545)),in(asset.marketplace.id,(MP-123)),' + 'in(asset.connection.hub.id,(HB-123)))' + ), value=[billing_request], ), ) @@ -109,7 +115,10 @@ def test_generate_csv_renderer(progress, client_factory, response_factory, billi ) responses.append( response_factory( - query='and(ge(created,2020-12-01T00:00:00),le(created,2021-01-01T00:00:00))', + query=( + 'and(ge(events.created.at,2020-12-01T00:00:00),' + 'le(events.created.at,2021-01-01T00:00:00))' + ), value=[billing_request], ), ) @@ -133,7 +142,10 @@ def test_generate_json_renderer(progress, client_factory, response_factory, bill ) responses.append( response_factory( - query='and(ge(created,2020-12-01T00:00:00),le(created,2021-01-01T00:00:00))', + query=( + 'and(ge(events.created.at,2020-12-01T00:00:00),' + 'le(events.created.at,2021-01-01T00:00:00))' + ), value=[billing_request], ), )