|
| 1 | +//! The full-refresh and incremental bodies of the text plan. |
| 2 | +
|
| 3 | +use crate::cli_text::_helpers::layout::surface_header; |
| 4 | +use crate::cli_text::_helpers::plan_sections::{ |
| 5 | + full_refresh_count_lines, functions_lines, plan_name_width, provider_usage_lines, pruned_lines, |
| 6 | + python_entry_lines, ready_summary, reason_group_lines, remaining_stale_lines, |
| 7 | + routine_model_lines, seed_lines, source_freshness_lines, source_load_lines, warning_lines, |
| 8 | +}; |
| 9 | +use crate::cli_text::_helpers::tree_rows::treeify; |
| 10 | +use crate::cli_text::constants::{ |
| 11 | + PLAN_READY_TITLE, PRE_SQL_INGRESS_PHASE, PYTHON_INGRESS_TITLE, PYTHON_READ_SIDE_TITLE, |
| 12 | + READ_SIDE_PHASE, |
| 13 | +}; |
| 14 | +use crate::cli_text::models::{CliStyle, ModelPlanText, PlanTextReport}; |
| 15 | + |
| 16 | +fn header_lines(report: &PlanTextReport, full_refresh: bool) -> Vec<String> { |
| 17 | + if !report.include_header { |
| 18 | + return Vec::new(); |
| 19 | + } |
| 20 | + vec![surface_header( |
| 21 | + CliStyle { use_color: true }, |
| 22 | + PLAN_READY_TITLE, |
| 23 | + &ready_summary(report, full_refresh), |
| 24 | + )] |
| 25 | +} |
| 26 | + |
| 27 | +/// Every active model is a full refresh: counts by materialization instead of detail. |
| 28 | +pub(crate) fn full_refresh_lines( |
| 29 | + report: &PlanTextReport, |
| 30 | + active: &[&ModelPlanText], |
| 31 | +) -> Vec<String> { |
| 32 | + let width: usize = plan_name_width(report); |
| 33 | + let mut lines: Vec<String> = header_lines(report, true); |
| 34 | + lines.extend(provider_usage_lines(report)); |
| 35 | + lines.extend(python_entry_lines( |
| 36 | + (report, PRE_SQL_INGRESS_PHASE, PYTHON_INGRESS_TITLE), |
| 37 | + width, |
| 38 | + )); |
| 39 | + lines.extend(source_load_lines(report, width)); |
| 40 | + lines.extend(functions_lines(report, true, width)); |
| 41 | + lines.extend(functions_lines(report, false, width)); |
| 42 | + if !lines.is_empty() { |
| 43 | + lines.push(String::new()); |
| 44 | + } |
| 45 | + lines.extend(full_refresh_count_lines(active)); |
| 46 | + lines.extend(seed_lines(report)); |
| 47 | + lines.extend(python_entry_lines( |
| 48 | + (report, READ_SIDE_PHASE, PYTHON_READ_SIDE_TITLE), |
| 49 | + width, |
| 50 | + )); |
| 51 | + lines.extend(warning_lines(report)); |
| 52 | + lines.extend(report.pre_build_lines.iter().cloned()); |
| 53 | + lines |
| 54 | +} |
| 55 | + |
| 56 | +/// Sections by change reason, drawn as trees. |
| 57 | +pub(crate) fn incremental_lines(report: &PlanTextReport, active: &[&ModelPlanText]) -> Vec<String> { |
| 58 | + let width: usize = plan_name_width(report); |
| 59 | + let mut lines: Vec<String> = header_lines(report, false); |
| 60 | + if report.include_freshness_diagnostics { |
| 61 | + lines.extend(source_freshness_lines(report)); |
| 62 | + } |
| 63 | + lines.extend(remaining_stale_lines(report)); |
| 64 | + lines.extend(provider_usage_lines(report)); |
| 65 | + lines.extend(pruned_lines(report)); |
| 66 | + lines.extend(report.pre_build_lines.iter().cloned()); |
| 67 | + lines.extend(python_entry_lines( |
| 68 | + (report, PRE_SQL_INGRESS_PHASE, PYTHON_INGRESS_TITLE), |
| 69 | + width, |
| 70 | + )); |
| 71 | + lines.extend(source_load_lines(report, width)); |
| 72 | + lines.extend(functions_lines(report, true, width)); |
| 73 | + lines.extend(reason_group_lines(report, active, width)); |
| 74 | + lines.extend(routine_model_lines(report, active, width)); |
| 75 | + lines.extend(functions_lines(report, false, width)); |
| 76 | + lines.extend(seed_lines(report)); |
| 77 | + lines.extend(python_entry_lines( |
| 78 | + (report, READ_SIDE_PHASE, PYTHON_READ_SIDE_TITLE), |
| 79 | + width, |
| 80 | + )); |
| 81 | + let mut lines: Vec<String> = treeify(lines); |
| 82 | + lines.extend(warning_lines(report)); |
| 83 | + lines |
| 84 | +} |
0 commit comments