use std::path::{Path, PathBuf};
use tracing::debug;
use crate::report::errors::Result;
use crate::report::models::ReportData;
pub const REPORT_JSON: &str = "report.json";
pub const VELOCITY_JSON: &str = "velocity_summary.json";
pub const QUALITY_JSON: &str = "quality_summary.json";
pub const DORA_JSON: &str = "dora_summary.json";
pub fn write_velocity_json(data: &ReportData, output_dir: &Path) -> Result<PathBuf> {
let path = output_dir.join(VELOCITY_JSON);
let file = std::fs::File::create(&path)?;
serde_json::to_writer_pretty(file, &data.velocity)?;
debug!(path = %path.display(), "wrote velocity_summary.json");
Ok(path)
}
pub fn write_quality_json(data: &ReportData, output_dir: &Path) -> Result<PathBuf> {
let path = output_dir.join(QUALITY_JSON);
let file = std::fs::File::create(&path)?;
serde_json::to_writer_pretty(file, &data.quality)?;
debug!(path = %path.display(), "wrote quality_summary.json");
Ok(path)
}
pub fn write_dora_json(data: &ReportData, output_dir: &Path) -> Result<PathBuf> {
let path = output_dir.join(DORA_JSON);
let file = std::fs::File::create(&path)?;
serde_json::to_writer_pretty(file, &data.dora)?;
debug!(path = %path.display(), "wrote dora_summary.json");
Ok(path)
}
pub fn write_json(data: &ReportData, output_dir: &Path) -> Result<PathBuf> {
let path = output_dir.join(REPORT_JSON);
let file = std::fs::File::create(&path)?;
serde_json::to_writer_pretty(file, data)?;
debug!(path = %path.display(), "wrote report.json");
Ok(path)
}