pub const ENV_TOKEN: &str = "GITHUB_TOKEN";
pub const DATE_LAYOUT: &str = "%Y-%m-%d";
pub const TIME_LAYOUT: &str = "%Y-%m-%d %H:%M:%S";
pub const API_BASE_URL: &str = "https://api.github.com";
pub const PER_PAGE: u32 = 100;
pub const OUTPUT_PREFIX: &str = "contributions";
pub const MAX_WORKERS: usize = 10;
const REPOSITORY_STR_LEN: usize = 13;
const SEPARATOR_WIDTH: usize = 60;
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Repository {
pub name: String,
}
#[derive(Debug, Clone, serde::Deserialize)]
pub struct CommitResponse {
pub commit: Commit,
}
#[derive(Debug, Clone, serde::Deserialize)]
pub struct Commit {
pub author: CommitAuthor,
pub message: String,
}
#[derive(Debug, Clone, serde::Deserialize)]
pub struct CommitAuthor {
pub date: String,
}
#[derive(Debug, Clone)]
pub struct GhContribConfig {
pub username: String,
pub since: String,
pub until: String,
pub token: String,
pub fetch_readme: bool,
}
#[derive(Debug, Clone)]
pub struct CommitInfo {
pub date: String,
pub subject: String,
pub body: String,
}
#[derive(Debug)]
pub struct RepoResult {
pub repo_name: String,
pub commits: Vec<CommitInfo>,
pub error: Option<String>,
pub readme_content: Option<String>,
}
pub fn repo_separator(username: &str, repo_name: &str) -> String {
let width = repo_name.len() + username.len() + REPOSITORY_STR_LEN;
"-".repeat(width)
}
pub fn header_separator() -> String {
"=".repeat(SEPARATOR_WIDTH)
}
pub fn summary_separator() -> String {
"-".repeat(SEPARATOR_WIDTH)
}
pub fn output_filename(username: &str, since: &str, until: &str) -> String {
format!("{OUTPUT_PREFIX}_{username}_{since}_to_{until}.txt")
}