Skip to content

Commit

Permalink
refactor: add ability to set history duration
Browse files Browse the repository at this point in the history
  • Loading branch information
azat-io committed Oct 16, 2024
1 parent 2285ca6 commit cfac0a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/get_history.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use crate::exec::exec;

pub async fn get_history() -> Vec<(String, String)> {
pub async fn get_history(months: Option<u32>) -> Vec<(String, String)> {
let since_period = months
.map(|m| format!("{} months ago", m))
.unwrap_or_else(|| "3 month ago".to_string());

let git_log_command = [
"git",
"log",
"--since=1 year ago",
&format!("--since={}", since_period),
"--pretty=format:%H %ad",
"--date=short",
];
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async fn main() {

todos_with_blame.sort_by(|a, b| a.blame.date.cmp(&b.blame.date));

let mut history: Vec<(String, String)> = get_history().await;
let mut history: Vec<(String, String)> = get_history(Some(3)).await;
let mut todo_count: usize = todos_with_blame.len();

let temp_file = File::create("todo_history_temp.json").expect("Failed to create temp file");
Expand Down

0 comments on commit cfac0a7

Please sign in to comment.