Skip to main content

oxirs_samm/analytics/
modelanalytics_generate_html_report_group.rs

1//! # ModelAnalytics - generate_html_report_group Methods
2//!
3//! This module contains method implementations for `ModelAnalytics`.
4//!
5//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
6
7use super::modelanalytics_type::ModelAnalytics;
8use crate::analytics::Severity;
9use std::collections::{HashMap, HashSet};
10
11impl ModelAnalytics {
12    /// Generate HTML report (for visualization)
13    pub fn generate_html_report(&self) -> String {
14        format!(
15            r#"<!DOCTYPE html>
16<html>
17<head>
18    <title>Model Analytics Report</title>
19    <style>
20        body {{ font-family: Arial, sans-serif; margin: 20px; }}
21        .score {{ font-size: 48px; font-weight: bold; color: {}; }}
22        .section {{ margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }}
23        .metric {{ margin: 10px 0; }}
24        .recommendation {{ padding: 10px; margin: 5px 0; background: #fff3cd; border-left: 4px solid #ffc107; }}
25        .error {{ border-left-color: #dc3545; background: #f8d7da; }}
26        .warning {{ border-left-color: #ffc107; background: #fff3cd; }}
27    </style>
28</head>
29<body>
30    <h1>Model Analytics Report</h1>
31    <div class="section">
32        <h2>Quality Score</h2>
33        <div class="score">{:.1}/100</div>
34    </div>
35    <div class="section">
36        <h2>Complexity Assessment</h2>
37        <div class="metric">Overall Level: <strong>{:?}</strong></div>
38        <div class="metric">Structural: {:.1}</div>
39        <div class="metric">Cognitive: {:.1}</div>
40        <div class="metric">Coupling: {:.1}</div>
41    </div>
42    <div class="section">
43        <h2>Best Practices</h2>
44        <div class="metric">Compliance: {:.1}% ({}/{})</div>
45    </div>
46    <div class="section">
47        <h2>Recommendations</h2>
48        {}
49    </div>
50</body>
51</html>"#,
52            if self.quality_score >= 80.0 {
53                "#28a745"
54            } else if self.quality_score >= 60.0 {
55                "#ffc107"
56            } else {
57                "#dc3545"
58            },
59            self.quality_score,
60            self.complexity_assessment.overall_level,
61            self.complexity_assessment.structural,
62            self.complexity_assessment.cognitive,
63            self.complexity_assessment.coupling,
64            self.best_practices.compliance_percentage,
65            self.best_practices.passed_checks,
66            self.best_practices.total_checks,
67            self.recommendations
68                .iter()
69                .map(|r| format!(
70                    r#"<div class="recommendation {}">{}: {} - {}</div>"#,
71                    match r.severity {
72                        Severity::Error | Severity::Critical => "error",
73                        _ => "warning",
74                    },
75                    r.severity,
76                    r.message,
77                    r.suggested_action
78                ))
79                .collect::<Vec<_>>()
80                .join("\n")
81        )
82    }
83}