ralph/queue/operations/batch/
display.rs1use super::BatchOperationResult;
17
18pub fn print_batch_results(result: &BatchOperationResult, operation_name: &str, dry_run: bool) {
20 if dry_run {
21 println!(
22 "Dry run - would perform {} on {} tasks:",
23 operation_name, result.total
24 );
25 for r in &result.results {
26 if r.success {
27 println!(" - {}: would update", r.task_id);
28 } else {
29 println!(
30 " - {}: would fail - {}",
31 r.task_id,
32 r.error.as_deref().unwrap_or("unknown error")
33 );
34 }
35 }
36 println!("Dry run complete. No changes made.");
37 return;
38 }
39
40 let created_count: usize = result
42 .results
43 .iter()
44 .map(|r| r.created_task_ids.len())
45 .sum();
46
47 if result.has_failures() {
48 println!("{} completed with errors:", operation_name);
49 for r in &result.results {
50 if r.success {
51 println!(" ✓ {}: updated", r.task_id);
52 if !r.created_task_ids.is_empty() {
53 for created_id in &r.created_task_ids {
54 println!(" → Created: {}", created_id);
55 }
56 }
57 } else {
58 println!(
59 " ✗ {}: failed - {}",
60 r.task_id,
61 r.error.as_deref().unwrap_or("unknown error")
62 );
63 }
64 }
65 println!(
66 "Completed: {}/{} tasks updated successfully.",
67 result.succeeded, result.total
68 );
69 if created_count > 0 {
70 println!("Created {} new tasks.", created_count);
71 }
72 } else {
73 println!("{} completed successfully:", operation_name);
74 for r in &result.results {
75 println!(" ✓ {}", r.task_id);
76 if !r.created_task_ids.is_empty() {
77 for created_id in &r.created_task_ids {
78 println!(" → Created: {}", created_id);
79 }
80 }
81 }
82 println!("Updated {} tasks.", result.succeeded);
83 if created_count > 0 {
84 println!("Created {} new tasks.", created_count);
85 }
86 }
87}