From 2ba568457eaf9b5a93ddae48a67d8068178f3dc0 Mon Sep 17 00:00:00 2001 From: Corey Goodfred Date: Thu, 3 Aug 2023 09:53:34 -0400 Subject: [PATCH] [COST-3892] split Identity/TimeInterval into start and end to have aware timestamps for SUBS (#4609) --- koku/subs/subs_data_messenger.py | 4 ++-- koku/subs/test/test_subs_data_messenger.py | 4 ++-- koku/subs/trino_sql/aws_subs_summary.sql | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/koku/subs/subs_data_messenger.py b/koku/subs/subs_data_messenger.py index 214261d374..21c915d65b 100644 --- a/koku/subs/subs_data_messenger.py +++ b/koku/subs/subs_data_messenger.py @@ -57,8 +57,8 @@ def process_and_send_subs_message(self, upload_keys): msg = self.build_subs_msg( row["lineitem_resourceid"], row["lineitem_usageaccountid"], - row["lineitem_usagestartdate"], - row["lineitem_usageenddate"], + row["subs_start_time"], + row["subs_end_time"], row["product_vcpu"], row["subs_sla"], row["subs_usage"], diff --git a/koku/subs/test/test_subs_data_messenger.py b/koku/subs/test/test_subs_data_messenger.py index 46c0113538..dd246b6ddc 100644 --- a/koku/subs/test/test_subs_data_messenger.py +++ b/koku/subs/test/test_subs_data_messenger.py @@ -32,8 +32,8 @@ def test_process_and_send_subs_message(self, mock_msg_builder, mock_reader, mock upload_keys = ["fake_key"] mock_reader.return_value = [ { - "lineitem_usagestartdate": "2023-07-01T01:00:00Z", - "lineitem_usageenddate": "2023-07-01T02:00:00Z", + "subs_start_time": "2023-07-01T01:00:00Z", + "subs_end_time": "2023-07-01T02:00:00Z", "lineitem_resourceid": "i-55555556", "lineitem_usageaccountid": "9999999999999", "physical_cores": "1", diff --git a/koku/subs/trino_sql/aws_subs_summary.sql b/koku/subs/trino_sql/aws_subs_summary.sql index c9aa20a1d1..15c82ab52a 100644 --- a/koku/subs/trino_sql/aws_subs_summary.sql +++ b/koku/subs/trino_sql/aws_subs_summary.sql @@ -1,5 +1,7 @@ SELECT *, + time_split[1] as subs_start_time, + time_split[2] as subs_end_time, CASE lower(json_extract_scalar(tags, '$.com_redhat_rhel_variant')) WHEN 'workstation' THEN 'Red Hat Enterprise Linux Workstation' ELSE 'Red Hat Enterprise Linux Server' @@ -22,6 +24,7 @@ SELECT FROM ( SELECT *, + split(identity_timeinterval, '/') as time_split, cast( transform_keys( map_filter(