87 lines
2.5 KiB
Rust
87 lines
2.5 KiB
Rust
use crate::actions::action::ProcessedMagnets;
|
|
use color_eyre::eyre::Result;
|
|
use console::{style, Emoji};
|
|
use log::info;
|
|
use std::collections::HashMap;
|
|
|
|
static SPARKLES: Emoji = Emoji("✨", ":sparkles:");
|
|
static ROCKET: Emoji = Emoji("🚀", ":rocket:");
|
|
static LINK: Emoji = Emoji("🔗", ":link:");
|
|
static WARNING: Emoji = Emoji("⚠️", ":warning:");
|
|
|
|
/// Generate a report of processed magnets
|
|
pub fn generate_report(
|
|
action_results: &HashMap<String, ProcessedMagnets>,
|
|
total_new_links: usize,
|
|
) -> Result<()> {
|
|
info!("");
|
|
info!(
|
|
"{} {} {}",
|
|
SPARKLES,
|
|
style("Report Summary").bold().underlined(),
|
|
style(format!(
|
|
"{} new links added to the database",
|
|
total_new_links
|
|
))
|
|
.bold()
|
|
.green(),
|
|
);
|
|
info!("");
|
|
|
|
for (action_name, processed_magnets) in action_results {
|
|
let success_count = processed_magnets.success.len();
|
|
let failed_count = processed_magnets.failed.len();
|
|
let total_count = success_count + failed_count;
|
|
|
|
// Section header for each action
|
|
info!("");
|
|
info!(
|
|
"{} {} {}",
|
|
ROCKET,
|
|
style(format!("{}", action_name)).bold().underlined().cyan(),
|
|
style(format!("({} new links)", total_count)).bold()
|
|
);
|
|
|
|
// Success/failure summary
|
|
if failed_count > 0 {
|
|
info!(
|
|
" {} Success: {}, {} Failure: {}",
|
|
style("✅").green(),
|
|
style(success_count).bold().green(),
|
|
style("❌").red(),
|
|
style(failed_count).bold().red()
|
|
);
|
|
} else {
|
|
info!(
|
|
" {} Success: {}",
|
|
style("✅").green(),
|
|
style(success_count).bold().green()
|
|
);
|
|
}
|
|
info!("");
|
|
|
|
// List successful magnets
|
|
if success_count > 0 {
|
|
info!(
|
|
" {} {}",
|
|
style("✅").green(),
|
|
style("Added:").bold().green()
|
|
);
|
|
for magnet in &processed_magnets.success {
|
|
info!(" {} {}", LINK, style(&magnet.title).italic());
|
|
}
|
|
info!("");
|
|
}
|
|
|
|
// List failed magnets
|
|
if failed_count > 0 {
|
|
info!(" {} {}", style("❌").red(), style("Failed:").bold().red());
|
|
for magnet in &processed_magnets.failed {
|
|
info!(" {} {}", WARNING, style(&magnet.title).italic());
|
|
}
|
|
info!("");
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|