@@ -360,15 +360,56 @@ fn analyze_activity(repo_path: &PathBuf, json_output: bool) -> Result<()> {
360360 }
361361
362362 println ! ( "\n 📊 Commit Activity by Hour:" ) ;
363- for hour in 0 ..24 {
364- let count = hourly_commits. get ( & hour) . unwrap_or ( & 0 ) ;
365- println ! ( "{:02}:00 - {:02}:59: {} commits" , hour, hour, count) ;
366- }
363+ display_hourly_chart ( & hourly_commits) ;
367364 }
368365
369366 Ok ( ( ) )
370367}
371368
369+ fn display_hourly_chart ( hourly_commits : & HashMap < u8 , u32 > ) {
370+ let max_commits = hourly_commits. values ( ) . max ( ) . unwrap_or ( & 0 ) ;
371+ let max_bar_width = 50 ; // Maximum width of the bar chart
372+
373+ for hour in 0 ..24 {
374+ let count = hourly_commits. get ( & hour) . unwrap_or ( & 0 ) ;
375+ let bar_width = if * max_commits > 0 {
376+ ( ( count * max_bar_width) / max_commits) . max ( if * count > 0 { 1 } else { 0 } )
377+ } else {
378+ 0
379+ } ;
380+
381+ let bar = "█" . repeat ( bar_width as usize ) ;
382+ let empty_bar = "░" . repeat ( ( max_bar_width - bar_width) as usize ) ;
383+
384+ // Add time period indicators
385+ let period_indicator = match hour {
386+ 0 ..=5 => "🌙" , // Night
387+ 6 ..=8 => "🌅" , // Early morning
388+ 9 ..=17 => "☀️" , // Day/Work hours
389+ 18 ..=21 => "🌆" , // Evening
390+ _ => "🌙" , // Late night
391+ } ;
392+
393+ println ! ( "{} {:02}:00-{:02}:59 │{}{} {} commits" ,
394+ period_indicator,
395+ hour,
396+ ( hour + 1 ) % 24 ,
397+ bar,
398+ empty_bar,
399+ count
400+ ) ;
401+ }
402+
403+ println ! ( "\n Legend: 🌙 Night 🌅 Morning ☀️ Day 🌆 Evening" ) ;
404+ println ! ( "Scale: Each █ represents {} commit(s)" ,
405+ if * max_commits > max_bar_width {
406+ ( * max_commits as f32 / max_bar_width as f32 ) . ceil( ) as u32
407+ } else {
408+ 1
409+ }
410+ ) ;
411+ }
412+
372413fn collect_activity_data ( repo : & Repository ) -> Result < ( HashMap < String , u32 > , HashMap < u8 , u32 > ) > {
373414 let mut monthly_commits: HashMap < String , u32 > = HashMap :: new ( ) ;
374415 let mut hourly_commits: HashMap < u8 , u32 > = HashMap :: new ( ) ;
0 commit comments