Initial upload: GitPulse - Developer Productivity Analyzer CLI tool
This commit is contained in:
76
src/models/author.rs
Normal file
76
src/models/author.rs
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct AuthorStats {
|
||||||
|
pub name: String,
|
||||||
|
pub email: String,
|
||||||
|
pub commits: usize,
|
||||||
|
pub lines_added: usize,
|
||||||
|
pub lines_removed: usize,
|
||||||
|
pub net_change: i64,
|
||||||
|
pub files_changed: usize,
|
||||||
|
pub first_commit: String,
|
||||||
|
pub last_commit: String,
|
||||||
|
pub active_days: usize,
|
||||||
|
pub average_commits_per_day: f64,
|
||||||
|
pub busiest_day: String,
|
||||||
|
pub busiest_day_count: usize,
|
||||||
|
pub commit_messages: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for AuthorStats {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
name: String::new(),
|
||||||
|
email: String::new(),
|
||||||
|
commits: 0,
|
||||||
|
lines_added: 0,
|
||||||
|
lines_removed: 0,
|
||||||
|
net_change: 0,
|
||||||
|
files_changed: 0,
|
||||||
|
first_commit: String::new(),
|
||||||
|
last_commit: String::new(),
|
||||||
|
active_days: 0,
|
||||||
|
average_commits_per_day: 0.0,
|
||||||
|
busiest_day: String::new(),
|
||||||
|
busiest_day_count: 0,
|
||||||
|
commit_messages: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct AuthorIdentity {
|
||||||
|
pub primary_name: String,
|
||||||
|
pub emails: Vec<String>,
|
||||||
|
pub aliases: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AuthorIdentity {
|
||||||
|
pub fn new(name: String) -> Self {
|
||||||
|
Self {
|
||||||
|
primary_name: name,
|
||||||
|
emails: Vec::new(),
|
||||||
|
aliases: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_email(&mut self, email: String) {
|
||||||
|
if !self.emails.contains(&email) {
|
||||||
|
self.emails.push(email);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn add_alias(&mut self, alias: String) {
|
||||||
|
if !self.aliases.contains(&alias) && alias != self.primary_name {
|
||||||
|
self.aliases.push(alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn matches(&self, name: &str, email: &str) -> bool {
|
||||||
|
name == self.primary_name
|
||||||
|
|| self.aliases.contains(&name.to_string())
|
||||||
|
|| self.emails.contains(&email.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user