use super::calculator::RatioStatsCalculator;
use super::insights::InsightsAnalyzer;
use super::types::{QualityThresholds, RatioStats};
use crate::core::types::{CodeStats, FileStats};
use crate::utils::errors::Result;
pub struct RatioStatsManager {
calculator: RatioStatsCalculator,
insights_analyzer: InsightsAnalyzer,
}
impl RatioStatsManager {
pub fn new() -> Self {
Self {
calculator: RatioStatsCalculator::new(),
insights_analyzer: InsightsAnalyzer::new(),
}
}
pub fn with_thresholds(thresholds: QualityThresholds) -> Self {
Self {
calculator: RatioStatsCalculator::with_thresholds(thresholds),
insights_analyzer: InsightsAnalyzer::new(),
}
}
pub fn calculate_file_ratios(&self, file_stats: &FileStats) -> Result<RatioStats> {
self.calculator.calculate_ratio_stats(file_stats)
}
pub fn calculate_project_ratios(&self, code_stats: &CodeStats) -> Result<RatioStats> {
self.calculator.calculate_project_ratio_stats(code_stats)
}
pub fn get_insights(&self, stats: &RatioStats) -> Vec<String> {
self.insights_analyzer.get_ratio_insights(stats)
}
pub fn get_most_documented_language(&self, stats: &RatioStats) -> Option<(String, f64)> {
self.insights_analyzer.get_most_documented_language(stats)
}
pub fn get_most_efficient_language(&self, stats: &RatioStats) -> Option<(String, f64)> {
self.insights_analyzer.get_most_efficient_language(stats)
}
pub fn get_quality_level(&self, score: f64) -> String {
self.calculator.get_quality_level(score)
}
pub fn get_quality_class(&self, score: f64) -> String {
self.calculator.get_quality_class(score)
}
pub fn get_thresholds(&self) -> &QualityThresholds {
self.calculator.get_thresholds()
}
pub fn set_thresholds(&mut self, thresholds: QualityThresholds) {
self.calculator.set_thresholds(thresholds);
}
pub fn calculator(&self) -> &RatioStatsCalculator {
&self.calculator
}
pub fn insights_analyzer(&self) -> &InsightsAnalyzer {
&self.insights_analyzer
}
}
impl Default for RatioStatsManager {
fn default() -> Self {
Self::new()
}
}