@@ -53,16 +53,16 @@ impl<'a> Repo<'a> {
53
53
pub fn get_authors ( & self , n : usize ) -> Vec < ( String , usize , usize ) > {
54
54
let mut authors = std:: collections:: HashMap :: new ( ) ;
55
55
let mut author_name_by_email = std:: collections:: HashMap :: new ( ) ;
56
- let mut total_commits = 0 ;
56
+ let mut total_nbr_of_commits = 0 ;
57
57
for commit in & self . logs {
58
58
let author = commit. author ( ) ;
59
59
let author_name = String :: from_utf8_lossy ( author. name_bytes ( ) ) . into_owned ( ) ;
60
60
let author_email = String :: from_utf8_lossy ( author. email_bytes ( ) ) . into_owned ( ) ;
61
61
62
- let commit_count = authors. entry ( author_email. to_string ( ) ) . or_insert ( 0 ) ;
62
+ let author_nbr_of_commits = authors. entry ( author_email. to_string ( ) ) . or_insert ( 0 ) ;
63
63
author_name_by_email. entry ( author_email. to_string ( ) ) . or_insert ( author_name) ;
64
- * commit_count += 1 ;
65
- total_commits += 1 ;
64
+ * author_nbr_of_commits += 1 ;
65
+ total_nbr_of_commits += 1 ;
66
66
}
67
67
68
68
let mut authors: Vec < ( String , usize ) > = authors. into_iter ( ) . collect ( ) ;
@@ -72,11 +72,12 @@ impl<'a> Repo<'a> {
72
72
73
73
let authors: Vec < ( String , usize , usize ) > = authors
74
74
. into_iter ( )
75
- . map ( |( author , count ) | {
75
+ . map ( |( author_email , author_nbr_of_commits ) | {
76
76
(
77
- author_name_by_email. get ( & author) . unwrap ( ) . trim_matches ( '\'' ) . to_string ( ) ,
78
- count,
79
- count * 100 / total_commits,
77
+ author_name_by_email. get ( & author_email) . unwrap ( ) . trim_matches ( '\'' ) . to_string ( ) ,
78
+ author_nbr_of_commits,
79
+ ( author_nbr_of_commits as f32 * 100. / total_nbr_of_commits as f32 ) . round ( )
80
+ as usize ,
80
81
)
81
82
} )
82
83
. collect ( ) ;
0 commit comments