@@ -95,11 +95,11 @@ def get_report_periods_before_date(self, date):
9595 """Get the report periods with report period before provided date."""
9696 return OCPUsageReportPeriod .objects .filter (report_period_start__lte = date )
9797
98- def populate_ui_summary_tables (self , start_date , end_date , source_uuid , tables = UI_SUMMARY_TABLES ):
98+ def populate_ui_summary_tables (self , summary_range : SummaryRangeConfig , source_uuid , tables = UI_SUMMARY_TABLES ):
9999 """Populate our UI summary tables (formerly materialized views)."""
100100 sql_params = {
101- "start_date" : start_date ,
102- "end_date" : end_date ,
101+ "start_date" : summary_range . start_date ,
102+ "end_date" : summary_range . end_date ,
103103 "schema" : self .schema ,
104104 "source_uuid" : source_uuid ,
105105 }
@@ -114,6 +114,9 @@ def populate_ui_summary_tables(self, start_date, end_date, source_uuid, tables=U
114114 sql_params ["month" ] = start_date .strftime ("%m" )
115115
116116 self ._populate_gpu_ui_summary_table_with_usage_only (sql_params )
117+ if summary_range .summarize_previous_month and not summary_range .is_current_month :
118+ # Don't resummarize virtualization UI table if we are summarizing previous month
119+ return
117120 self ._populate_virtualization_ui_summary_table (sql_params )
118121
119122 def _populate_gpu_ui_summary_table_with_usage_only (self , params ):
@@ -529,9 +532,6 @@ def populate_distributed_cost_sql(
529532 }
530533 # Handle distributions that require full month data
531534 if config .requires_full_month :
532- # Skip full-month distributions on subsequent days when iterating day-by-day
533- if summary_range .skip_full_month :
534- continue
535535 sql_params ["start_date" ] = summary_range .start_of_month
536536 sql_params ["end_date" ] = summary_range .end_of_month
537537 if summary_range .is_current_month :
@@ -540,6 +540,7 @@ def populate_distributed_cost_sql(
540540 if dh .now_utc .day in [1 , 2 , 3 ]:
541541 sql_params ["start_date" ] = summary_range .start_of_previous_month
542542 sql_params ["end_date" ] = summary_range .end_of_previous_month
543+ summary_range .summarize_previous_month = True
543544 else :
544545 msg = f"Skipping { cost_model_key } distribution requires full month"
545546 LOG .info (log_json (msg = msg , context = {"schema" : self .schema , "cost_model_key" : cost_model_key }))
0 commit comments