gitalytics 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d1b786805cf13c4a8f17b163afa2af25c980532
4
- data.tar.gz: d1d64351ecdc60d220c962826b615ccd446bda4d
3
+ metadata.gz: b4fb17f1fd09ae86b6c93b3c7283a1a755a7031e
4
+ data.tar.gz: 6b4a2d91bab135ba263a64421427a36cfdfe9044
5
5
  SHA512:
6
- metadata.gz: 1e7ce84f9931831e5121757d9df55b0f6e7eea8412cb855ef2b62c06681d692439b756b011e1188284f12d5a7e049a3866ea3c125f772b45bf1c3ff85df182c9
7
- data.tar.gz: 8fe319543970aed157f4003b2eabb4a544367b8123b086dc83e9795820fd98bebe0db642b27a35b51a37c996d78662cf2127bc70f1da525b070b3b58921cca15
6
+ metadata.gz: 7c3f613d51e99d4286500f8287af6c18e0adb2ae2af34830e9cb990006340daf8f6dac5b3ab1552db7a9ab0e458ad0e2ad95db530ec77f99c1cff34ac5bab7a2
7
+ data.tar.gz: c415721c1b02fa62343fb3b036a7ee1bc15790c2c28940711ea4315a8ea5be34e0f2ce4222622b16dc6c540f5a20e920bc1668176870b50365148490dbf8da62
@@ -61,14 +61,8 @@
61
61
  padding-right: 15px;
62
62
  }
63
63
 
64
- .media {
65
- height: 125px;
66
- margin-bottom: 20px;
67
- }
68
-
69
- .media-body {
70
- color: #444;
71
- font-size: 12px;
64
+ .user-avatar {
65
+ margin: 0 10px 10px 0;
72
66
  }
73
67
 
74
68
  .dp {
@@ -118,30 +112,27 @@
118
112
  <!-- Begin page content -->
119
113
  <div class="container">
120
114
  <div class="page-header">
121
- <h1>User stats</h1>
115
+ <h1>Users</h1>
122
116
  <p class="lead">Compare the quantity of commits made by each of your repository contributors.<br/> Check who is writing most of the code of your project and maybe give him/her a prize! ;)</p>
117
+ <% @data[:users].each do |user| %>
118
+ <a href="#" title="<%= user.name %> <small><%= user.email %></small>" class="user-avatar" data-content="<%= user.summary %>">
119
+ <img class="dp img-circle" src="<%= "http://www.gravatar.com/avatar/#{user.gravatar}" %>" style="width: 100px; height:100px; border-color:<%= user.rgba %>"></a>
120
+ <% end %>
123
121
  </div>
124
122
 
125
- <div class="col-md-5">
126
- <canvas id="myChart" width="400" height="400"></canvas>
127
- </div>
128
- <div class="col-md-7">
129
- <% @data[:users].each_with_index do |user, i| %>
130
- <div class="col-md-6">
131
- <div class="media">
132
- <a class="pull-left" href="#">
133
- <img class="media-object dp img-circle" src="<%= "http://www.gravatar.com/avatar/#{user.gravatar}" %>" style="width: 100px; height:100px; border-color:<%= "##{user.color}" %>">
134
- </a>
135
- <div class="media-body">
136
- <h4 class="media-heading"><%= user.name %><br><small><%= user.email %></small></h4>
137
- <hr style="margin:8px auto">
138
- <%= "#{user.commits.count} commits between #{user.commits_period} days." %>
139
- <%= "He did something useful on #{user.working_days} of those days." %>
140
- </div>
141
- </div>
142
- </div>
143
- <% end %>
123
+ <div class="row">
124
+ <div class="col-md-6">
125
+ <h2>Commits count per user</h2>
126
+ <canvas id="usersPieChart" width="550" height="400"></canvas>
127
+ </div>
128
+ <div class="col-md-6">
129
+ <h2>Commits per weekday per user</h2>
130
+ <canvas id="usersRadarChart" width="550" height="400"></canvas>
131
+ </div>
144
132
  </div>
133
+ <hr>
134
+ <h2>Insertions vs. Deletions</h2>
135
+ <canvas id="usersBarChart" width="1100" height="400"></canvas>
145
136
  </div>
146
137
  </div>
147
138
 
@@ -159,9 +150,51 @@
159
150
  <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
160
151
  <script src="http://cdnjs.cloudflare.com/ajax/libs/Chart.js/0.2.0/Chart.min.js"></script>
161
152
  <script>
162
- var data = [<%= @data[:users].map{|d| "{ value: #{d.commits.count}, color: '##{d.color}' }" }.join(',') %>];
163
- var ctx = document.getElementById("myChart").getContext("2d");
164
- var myNewChart = new Chart(ctx).Pie(data);
153
+ $('.user-avatar').popover({ trigger: 'hover', html: true }).click(function(e){
154
+ e.preventDefault();
155
+ });
156
+
157
+ // Data for Users Pie Chart
158
+ var data = [<%= @data[:users].map{|d| "{ value: #{d.commits.count}, color: '#{d.rgba}' }" }.join(',') %>];
159
+ var ctx = document.getElementById("usersPieChart").getContext("2d");
160
+ var usersPieChart = new Chart(ctx).Pie(data);
161
+
162
+ // Data for Insertions vs. Deletions Bar Chart
163
+ var data = {
164
+ labels: [<%= @data[:users].map{|d| "'#{d.name}'" }.join(',') %>],
165
+ datasets: [
166
+ {
167
+ data: [<%= @data[:users].map{|d| "#{d.total_insertions}" }.join(',') %>],
168
+ fillColor: 'rgba(196, 234, 44, 0.5)',
169
+ strokeColor: 'rgba(196, 234, 44, 1)'
170
+ },
171
+ {
172
+ data: [<%= @data[:users].map{|d| "#{d.total_deletions}" }.join(',') %>],
173
+ fillColor: 'rgba(234, 80, 44, 0.5)',
174
+ strokeColor: 'rgba(234, 80, 44, 1)'
175
+ }
176
+ ]
177
+ };
178
+ var ctx = document.getElementById("usersBarChart").getContext("2d");
179
+ var usersBarChart = new Chart(ctx).Bar(data);
180
+
181
+ // Data for Weekday commits per user
182
+ var data = {
183
+ labels: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
184
+ datasets: [
185
+ <% @data[:users].each_with_index do |user, i| %>
186
+ {
187
+ fillColor : "<%= user.rgba('0.5') %>",
188
+ strokeColor : "<%= user.rgba %>",
189
+ pointColor : "<%= user.rgba %>",
190
+ pointStrokeColor : "#fff",
191
+ data : [<%= user.weekday_commits.join(', ') %>]
192
+ }<%= ',' unless i + 1 == @data[:users].count %>
193
+ <% end %>
194
+ ]
195
+ };
196
+ var ctx = document.getElementById("usersRadarChart").getContext("2d");
197
+ var usersRadarChart = new Chart(ctx).Radar(data);
165
198
  </script>
166
199
  </body>
167
200
  </html>
data/lib/gitalytics.rb CHANGED
@@ -6,7 +6,7 @@ require 'digest/md5'
6
6
 
7
7
  class Gitalytics
8
8
 
9
- VERSION = '1.0.5'
9
+ VERSION = '1.1.0'
10
10
 
11
11
  attr_accessor :data
12
12
 
@@ -26,7 +26,7 @@ class Gitalytics
26
26
 
27
27
  private
28
28
  def parse_git_log
29
- result = `git log --stat`
29
+ result = `git log --stat`
30
30
 
31
31
  result.each_line do |line|
32
32
  if match = line.match(/^commit ([0-9a-z]*)$/)
@@ -48,7 +48,7 @@ class Gitalytics
48
48
 
49
49
  def output_cli_report
50
50
  @data[:users].each do |user|
51
- puts "#{user.name} has made #{user.commits.count} commits between #{user.commits_period} days. He did something useful on #{user.working_days} of those days."
51
+ puts user.summary
52
52
  end
53
53
  end
54
54
 
@@ -70,13 +70,13 @@ end
70
70
 
71
71
  class User
72
72
 
73
- attr_accessor :name, :email, :commits, :color
73
+ attr_accessor :name, :email, :commits, :colors
74
74
 
75
75
  def initialize(name, email)
76
76
  self.name = name
77
77
  self.email = email
78
78
  self.commits = []
79
- self.color = "%06x" % (rand * 0xffffff)
79
+ self.colors = [rand(255), rand(255), rand(255)].join(', ')
80
80
  end
81
81
 
82
82
  def gravatar
@@ -99,6 +99,30 @@ class User
99
99
  commits.map(&:date).uniq.count
100
100
  end
101
101
 
102
+ def total_insertions
103
+ commits.map(&:insertions).inject(0) { |total, current| total + current }
104
+ end
105
+
106
+ def total_deletions
107
+ commits.map(&:deletions).inject(0) { |total, current| total + current }
108
+ end
109
+
110
+ def summary
111
+ "#{name} has made #{commits.count} commits between #{commits_period} days. He/she did something useful on #{working_days} of those days."
112
+ end
113
+
114
+ def rgba(opacity = 1)
115
+ "rgba(#{colors}, #{opacity})"
116
+ end
117
+
118
+ def weekday_commits
119
+ days = Array.new(7) {0}
120
+ commits.each do |c|
121
+ days[c.date.wday] += 1
122
+ end
123
+ days
124
+ end
125
+
102
126
  end
103
127
 
104
128
  class Commit
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitalytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Robaina
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-06 00:00:00.000000000 Z
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Get usefull analytics from your git log
14
14
  email: gonzalor@gmail.com