Initial upload: Add repohealth-cli project with CI/CD workflow
This commit is contained in:
42
src/repohealth/models/author.py
Normal file
42
src/repohealth/models/author.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""Author statistics data models."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
@dataclass
|
||||
class AuthorStats:
|
||||
"""Statistics for a single author across the repository."""
|
||||
|
||||
name: str
|
||||
email: str
|
||||
total_commits: int = 0
|
||||
files_touched: set[str] = field(default_factory=set)
|
||||
first_commit: Optional[datetime] = None
|
||||
last_commit: Optional[datetime] = None
|
||||
modules_contributed: set[str] = field(default_factory=set)
|
||||
unique_contributions: int = 0
|
||||
total_contributions: int = 0
|
||||
|
||||
@property
|
||||
def ownership_percentage(self) -> float:
|
||||
"""Get percentage of total repository contributions."""
|
||||
return 0.0
|
||||
|
||||
def add_file(self, file_path: str, module: str) -> None:
|
||||
"""Record a contribution to a file."""
|
||||
self.files_touched.add(file_path)
|
||||
self.modules_contributed.add(module)
|
||||
self.total_contributions += 1
|
||||
|
||||
def merge(self, other: "AuthorStats") -> None:
|
||||
"""Merge another AuthorStats into this one."""
|
||||
self.total_commits += other.total_commits
|
||||
self.files_touched.update(other.files_touched)
|
||||
self.modules_contributed.update(other.modules_contributed)
|
||||
self.unique_contributions = len(self.files_touched)
|
||||
if other.first_commit and (not self.first_commit or other.first_commit < self.first_commit):
|
||||
self.first_commit = other.first_commit
|
||||
if other.last_commit and (not self.last_commit or other.last_commit > self.last_commit):
|
||||
self.last_commit = other.last_commit
|
||||
Reference in New Issue
Block a user