Skip to main content

ic_query_cli/presentation/report/
mod.rs

1//! Shared presentation of typed report provenance.
2
3use crate::presentation::text_value::field;
4use ic_query::report::ReportProvenance;
5
6/// Render source and complete-cache evidence in a stable human-facing order.
7pub fn push_report_provenance_lines(lines: &mut Vec<String>, provenance: &ReportProvenance) {
8    lines.push(field("data_source", &(provenance.data_source())));
9    if let Some(cache_path) = provenance.cache_path() {
10        lines.push(field("cache_path", &cache_path));
11        lines.push("cache_complete: yes".to_string());
12    }
13}
14
15#[cfg(test)]
16mod tests;
17
18///
19/// TextOptions
20///
21/// Caller-selected identity and summary detail for human-facing report rendering.
22///
23
24#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
25pub struct TextOptions {
26    /// Expand human-facing report detail.
27    pub verbose: bool,
28}
29
30/// Render shared refresh-attempt evidence with one human-facing field vocabulary.
31pub fn refresh_attempt_lines(
32    attempt: &ic_query::cache::SnapshotRefreshAttemptStatus,
33) -> [String; 8] {
34    crate::presentation::text_value::report_fields!(attempt;
35        attempt_status = attempt.status,
36        attempt_started_at = &attempt.started_at,
37        attempt_updated_at = &attempt.updated_at,
38        attempt_page_size = attempt.page_size,
39        attempt_pages_fetched = attempt.pages_fetched,
40        attempt_rows_fetched = attempt.rows_fetched,
41        attempt_last_cursor = crate::presentation::text_value::optional_text(attempt.last_cursor.as_ref()),
42        attempt_last_error = crate::presentation::text_value::optional_text(attempt.last_error.as_ref()),
43    )
44}