use std::collections::HashMap;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuthorSummary {
pub name: String,
pub email: String,
pub commit_count: usize,
pub insertions: i64,
pub deletions: i64,
pub files_changed: i64,
pub categories: HashMap<String, usize>,
pub first_commit: String,
pub last_commit: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RepositorySummary {
pub name: String,
pub commit_count: usize,
pub author_count: usize,
pub insertions: i64,
pub deletions: i64,
pub top_categories: Vec<(String, usize)>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WeeklyActivity {
pub week: String,
pub author: String,
pub repository: String,
pub commit_count: usize,
pub insertions: i64,
pub deletions: i64,
pub categories: HashMap<String, usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WeeklyMetrics {
pub week: String,
pub total_commits: usize,
pub feature_commits: usize,
pub bugfix_commits: usize,
pub maintenance_commits: usize,
pub refactor_commits: usize,
pub test_commits: usize,
pub doc_commits: usize,
pub active_developers: usize,
pub story_points: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeveloperActivitySummary {
pub developer_id: String,
pub display_name: String,
pub total_commits: usize,
pub active_weeks: usize,
pub avg_commits_per_week: f64,
pub primary_work_type: String,
pub story_points_total: f64,
pub activity_score: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReportSummary {
pub date_range: String,
pub total_commits: usize,
pub total_developers: usize,
pub total_weeks: usize,
pub classification_coverage_pct: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UntrackedCommit {
pub sha: String,
pub author: String,
pub date: String,
pub message: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WeeklyCategorization {
pub week: String,
pub change_type: String,
pub commit_count: usize,
pub pct_of_week: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WeeklyVelocity {
pub week: String,
pub prs_merged: usize,
pub avg_pr_cycle_time_hours: f64,
pub story_points: f64,
pub commits_per_developer: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DoraMetrics {
pub deployment_frequency: f64,
pub lead_time_hours: f64,
pub change_failure_rate: f64,
pub mttr_hours: f64,
pub performance_level: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VelocitySummary {
pub pr_cycle_time_avg_hours: f64,
pub pr_cycle_time_median_hours: f64,
pub pr_throughput_per_week: f64,
pub revision_rate: f64,
pub pr_count: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QualitySummary {
pub quality_score: f64,
pub revert_count: usize,
pub revert_pct: f64,
pub bugfix_pct: f64,
pub defect_rate: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActivityWeights {
pub commits: f64,
pub prs: f64,
pub code_impact: f64,
pub complexity: f64,
pub ticketing: f64,
}
impl Default for ActivityWeights {
fn default() -> Self {
Self {
commits: 0.22,
prs: 0.26,
code_impact: 0.26,
complexity: 0.11,
ticketing: 0.15,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReportData {
pub generated_at: String,
pub period_start: Option<String>,
pub period_end: Option<String>,
pub authors: Vec<AuthorSummary>,
pub repositories: Vec<RepositorySummary>,
pub weekly_activity: Vec<WeeklyActivity>,
pub total_commits: usize,
pub total_authors: usize,
pub category_breakdown: HashMap<String, usize>,
pub weekly_metrics: Vec<WeeklyMetrics>,
pub developer_activity: Vec<DeveloperActivitySummary>,
pub summary: Option<ReportSummary>,
pub untracked_commits: Vec<UntrackedCommit>,
pub weekly_categorization: Vec<WeeklyCategorization>,
pub weekly_velocity: Vec<WeeklyVelocity>,
pub dora: Option<DoraMetrics>,
pub velocity: Option<VelocitySummary>,
pub quality: Option<QualitySummary>,
pub boilerplate_count: usize,
pub revert_count: usize,
#[serde(default)]
pub repository_coverage: usize,
#[serde(default)]
pub unresolved_author_commits: usize,
#[serde(default)]
pub unresolved_authors: usize,
}
impl ReportData {
pub fn empty(generated_at: String) -> Self {
Self {
generated_at,
period_start: None,
period_end: None,
authors: Vec::new(),
repositories: Vec::new(),
weekly_activity: Vec::new(),
total_commits: 0,
total_authors: 0,
category_breakdown: HashMap::new(),
weekly_metrics: Vec::new(),
developer_activity: Vec::new(),
summary: None,
untracked_commits: Vec::new(),
weekly_categorization: Vec::new(),
weekly_velocity: Vec::new(),
dora: None,
velocity: None,
quality: None,
boilerplate_count: 0,
revert_count: 0,
repository_coverage: 0,
unresolved_author_commits: 0,
unresolved_authors: 0,
}
}
}