Skip to content

Commit 54f2421

Browse files
authored
AWS Tags: Remove unutilized pathway. (#4903)
1 parent 1b4e10a commit 54f2421

5 files changed

+0
-135
lines changed

koku/masu/database/aws_report_db_accessor.py

-46
Original file line numberDiff line numberDiff line change
@@ -339,52 +339,6 @@ def populate_markup_cost(self, provider_uuid, markup, start_date, end_date, bill
339339
source_uuid=provider_uuid, source_type=Provider.PROVIDER_AWS, **date_filters
340340
).update(markup_cost=(F("unblended_cost") * markup))
341341

342-
def populate_enabled_tag_keys(self, start_date, end_date, bill_ids):
343-
"""Populate the enabled tag key table.
344-
345-
Args:
346-
start_date (datetime.date) The date to start populating the table.
347-
end_date (datetime.date) The date to end on.
348-
bill_ids (list) A list of bill IDs.
349-
350-
Returns
351-
(None)
352-
"""
353-
table_name = "reporting_enabledtagkeys"
354-
sql = pkgutil.get_data("masu.database", "sql/reporting_awsenabledtagkeys.sql")
355-
sql = sql.decode("utf-8")
356-
sql_params = {
357-
"start_date": start_date,
358-
"end_date": end_date,
359-
"bill_ids": bill_ids,
360-
"schema": self.schema,
361-
}
362-
self._prepare_and_execute_raw_sql_query(table_name, sql, sql_params)
363-
364-
def update_line_item_daily_summary_with_enabled_tags(self, start_date, end_date, bill_ids):
365-
"""Populate the enabled tag key table.
366-
367-
Args:
368-
start_date (datetime.date) The date to start populating the table.
369-
end_date (datetime.date) The date to end on.
370-
bill_ids (list) A list of bill IDs.
371-
372-
Returns
373-
(None)
374-
"""
375-
table_name = self._table_map["line_item_daily_summary"]
376-
sql = pkgutil.get_data(
377-
"masu.database", "sql/reporting_awscostentryline_item_daily_summary_update_enabled_tags.sql"
378-
)
379-
sql = sql.decode("utf-8")
380-
sql_params = {
381-
"start_date": start_date,
382-
"end_date": end_date,
383-
"bill_ids": bill_ids,
384-
"schema": self.schema,
385-
}
386-
self._prepare_and_execute_raw_sql_query(table_name, sql, sql_params)
387-
388342
def get_openshift_on_cloud_matched_tags(self, aws_bill_id):
389343
"""Return a list of matched tags."""
390344
sql = pkgutil.get_data("masu.database", "sql/reporting_ocpaws_matched_tags.sql")

koku/masu/database/sql/reporting_awscostentryline_item_daily_summary_update_enabled_tags.sql

-17
This file was deleted.

koku/masu/database/sql/reporting_awsenabledtagkeys.sql

-25
This file was deleted.

koku/masu/processor/aws/aws_report_parquet_summary_updater.py

-2
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,9 @@ def update_summary_tables(self, start_date, end_date, **kwargs):
9999
start, end, self._provider.uuid, current_bill_id, markup_value
100100
)
101101
accessor.populate_ui_summary_tables(start, end, self._provider.uuid)
102-
# accessor.populate_enabled_tag_keys(start, end, bill_ids)
103102
accessor.populate_tags_summary_table(bill_ids, start_date, end_date)
104103
accessor.populate_category_summary_table(bill_ids, start_date, end_date)
105104

106-
# accessor.update_line_item_daily_summary_with_enabled_tags(start_date, end_date, bill_ids)
107105
for bill in bills:
108106
if bill.summary_data_creation_datetime is None:
109107
bill.summary_data_creation_datetime = timezone.now()

koku/masu/test/database/test_aws_report_db_accessor.py

-45
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
from reporting.provider.all.models import EnabledTagKeys
3333
from reporting.provider.aws.models import AWSCostEntryBill
3434
from reporting.provider.aws.models import AWSCostEntryLineItemDailySummary
35-
from reporting.provider.aws.models import AWSTagsSummary
3635

3736

3837
class AWSReportDBAccessorTest(MasuTestCase):
@@ -229,50 +228,6 @@ def test_populate_ocp_on_aws_cost_daily_summary_trino_memory_distribution(
229228
)
230229
mock_trino.assert_called()
231230

232-
def test_populate_enabled_tag_keys(self):
233-
"""Test that enabled tag keys are populated."""
234-
start_date = self.dh.this_month_start.date()
235-
end_date = self.dh.this_month_end.date()
236-
237-
bills = self.accessor.bills_for_provider_uuid(self.aws_provider_uuid, start_date)
238-
with schema_context(self.schema):
239-
AWSTagsSummary.objects.all().delete()
240-
EnabledTagKeys.objects.filter(provider_type=Provider.PROVIDER_AWS).delete()
241-
242-
bill_ids = [bill.id for bill in bills]
243-
self.assertEqual(EnabledTagKeys.objects.filter(provider_type=Provider.PROVIDER_AWS).count(), 0)
244-
self.accessor.populate_enabled_tag_keys(start_date, end_date, bill_ids)
245-
self.assertNotEqual(EnabledTagKeys.objects.filter(provider_type=Provider.PROVIDER_AWS).count(), 0)
246-
247-
def test_update_line_item_daily_summary_with_enabled_tags(self):
248-
"""Test that we filter the daily summary table's tags with only enabled tags."""
249-
start_date = self.dh.this_month_start.date()
250-
end_date = self.dh.this_month_end.date()
251-
252-
bills = self.accessor.bills_for_provider_uuid(self.aws_provider_uuid, start_date)
253-
with schema_context(self.schema):
254-
AWSTagsSummary.objects.all().delete()
255-
key_to_keep = EnabledTagKeys.objects.filter(provider_type=Provider.PROVIDER_AWS).filter(key="app").first()
256-
EnabledTagKeys.objects.filter(provider_type=Provider.PROVIDER_AWS).update(enabled=False)
257-
EnabledTagKeys.objects.filter(provider_type=Provider.PROVIDER_AWS).filter(key="app").update(enabled=True)
258-
bill_ids = [bill.id for bill in bills]
259-
self.accessor.update_line_item_daily_summary_with_enabled_tags(start_date, end_date, bill_ids)
260-
tags = (
261-
AWSCostEntryLineItemDailySummary.objects.filter(
262-
usage_start__gte=start_date, cost_entry_bill_id__in=bill_ids
263-
)
264-
.values_list("tags")
265-
.distinct()
266-
)
267-
268-
for tag in tags:
269-
tag_dict = tag[0]
270-
tag_keys = list(tag_dict.keys())
271-
if tag_keys:
272-
self.assertEqual([key_to_keep.key], tag_keys)
273-
else:
274-
self.assertEqual([], tag_keys)
275-
276231
def test_table_properties(self):
277232
self.assertEqual(self.accessor.line_item_daily_summary_table, get_model("AWSCostEntryLineItemDailySummary"))
278233

0 commit comments

Comments
 (0)