diff --git a/src/models/data_structures.py b/src/models/data_structures.py new file mode 100644 index 0000000..5203b62 --- /dev/null +++ b/src/models/data_structures.py @@ -0,0 +1,104 @@ +from dataclasses import dataclass, field +from datetime import datetime +from typing import List, Optional + +from dataclasses_json import dataclass_json + + +@dataclass_json +@dataclass +class Author: + """Represents a git author.""" + name: str + email: str + commit_count: int = 0 + lines_added: int = 0 + lines_deleted: int = 0 + + +@dataclass_json +@dataclass +class Commit: + """Represents a git commit.""" + sha: str + message: str + author: str + author_email: str + timestamp: datetime + lines_added: int = 0 + lines_deleted: int = 0 + files_changed: List[str] = field(default_factory=list) + is_merge: bool = False + is_revert: bool = False + + +@dataclass_json +@dataclass +class FileChange: + """Represents changes to a file in a commit.""" + filepath: str + lines_added: int + lines_deleted: int + change_type: str + + +@dataclass_json +@dataclass +class CommitAnalysis: + """Analysis of commit patterns.""" + total_commits: int + unique_authors: int + commits_by_hour: dict + commits_by_day: dict + commits_by_week: dict + top_authors: List[Author] + average_commits_per_day: float + + +@dataclass_json +@dataclass +class CodeChurnAnalysis: + """Analysis of code churn.""" + total_lines_added: int + total_lines_deleted: int + net_change: int + churn_by_file: dict + churn_by_author: dict + high_churn_commits: List[Commit] + average_churn_per_commit: float + + +@dataclass_json +@dataclass +class RiskyCommitAnalysis: + """Analysis of risky commits.""" + total_risky_commits: int + large_change_commits: List[Commit] + merge_commits: List[Commit] + revert_commits: List[Commit] + risk_score: float + + +@dataclass_json +@dataclass +class VelocityAnalysis: + """Analysis of team velocity.""" + commits_per_day: float + commits_per_week: float + commits_per_month: float + velocity_trend: str + top_contributors: List[Author] + most_active_day: str + most_active_hour: str + + +@dataclass_json +@dataclass +class ProductivityReport: + """Comprehensive productivity report.""" + repository_path: str + analysis_days: int + commit_analysis: Optional[CommitAnalysis] + code_churn_analysis: Optional[CodeChurnAnalysis] + risky_commit_analysis: Optional[RiskyCommitAnalysis] + velocity_analysis: Optional[VelocityAnalysis]