git-heroes 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddda5088666b7d915f39ca283765839033d28e0a
4
- data.tar.gz: 62f5ebea3d678988928f60902acb1711e2e00a45
3
+ metadata.gz: 12ef712b145c14252c41cee2921c9d32c09603ce
4
+ data.tar.gz: fa5841610ed26acbf0de489c53928edeb4c69683
5
5
  SHA512:
6
- metadata.gz: 7d2303a8aea29cb9b06fe92becffd36a8950ffbac98bda9a5cc11d70cebe55d1f6898912bdf1843d34c88524c89e6984da823bf0ea5311dcbde4b28278f15882
7
- data.tar.gz: 30a5a723b9877ebf60a9feebad39df26148da913ee4d92f1cd5e1402e8698a71a410fd247e515ea8cd820b810999ef2cda1eafa008bbef306e535e23888f9c5b
6
+ metadata.gz: 3d3354d161fc58d18523f81918d4a80d12dc41a86c90d82b6fecded4163ad41325fe3d10af0f10bee44aa5bbdf4737ea0020f72ae723b463951d06497ec71e5e
7
+ data.tar.gz: abb4fe4643aa035374daf58842e1bb8abc45365031839f942a0ba8c13648652a85c78949f64169531eebb5ded211e5790ec7db32b72c51a3a68bb28284580682
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
@@ -1 +1 @@
1
- 2.0.0-p247
1
+ 2.0.0-p353
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ git-heroes (0.0.2)
5
+ dotenv
6
+ faraday-http-cache
7
+ octokit
8
+ redis
9
+ redis-activesupport
10
+
11
+ GEM
12
+ remote: http://yarp.dev/
13
+ specs:
14
+ activesupport (4.0.2)
15
+ i18n (~> 0.6, >= 0.6.4)
16
+ minitest (~> 4.2)
17
+ multi_json (~> 1.3)
18
+ thread_safe (~> 0.1)
19
+ tzinfo (~> 0.3.37)
20
+ addressable (2.3.5)
21
+ atomic (1.1.14)
22
+ coderay (1.1.0)
23
+ dotenv (0.9.0)
24
+ faraday (0.9.0)
25
+ multipart-post (>= 1.2, < 3)
26
+ faraday-http-cache (0.4.0)
27
+ faraday (~> 0.8)
28
+ i18n (0.6.9)
29
+ method_source (0.8.2)
30
+ minitest (4.7.5)
31
+ multi_json (1.8.4)
32
+ multipart-post (2.0.0)
33
+ octokit (2.7.1)
34
+ sawyer (~> 0.5.2)
35
+ pry (0.9.12.6)
36
+ coderay (~> 1.0)
37
+ method_source (~> 0.8)
38
+ slop (~> 3.4)
39
+ pry-nav (0.2.3)
40
+ pry (~> 0.9.10)
41
+ rake (10.1.1)
42
+ redis (3.0.7)
43
+ redis-activesupport (4.0.0)
44
+ activesupport (~> 4)
45
+ redis-store (~> 1.1.0)
46
+ redis-store (1.1.4)
47
+ redis (>= 2.2)
48
+ sawyer (0.5.3)
49
+ addressable (~> 2.3.5)
50
+ faraday (~> 0.8, < 0.10)
51
+ slop (3.4.7)
52
+ thread_safe (0.1.3)
53
+ atomic
54
+ tzinfo (0.3.38)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ bundler (~> 1.3)
61
+ git-heroes!
62
+ pry
63
+ pry-nav
64
+ rake
data/README.md CHANGED
@@ -20,6 +20,13 @@ Redis instance for caching.
20
20
 
21
21
  $ git heroes -r <your-organization> -t <github-token>
22
22
 
23
+ Outputs two files, `report-timing.csv` (time taken to merge pull requests) and
24
+ `report-points.csv` (contribution points per user).
25
+
26
+ You'll probably want to pivot this in a spreadsheet application to get
27
+ meaningful results; if you want a template for that just email
28
+ [me](http://github.com/mezis).
29
+
23
30
  Details:
24
31
 
25
32
  Usage: bin/git-heroes [options]
@@ -30,6 +37,14 @@ Details:
30
37
  -v, --verbose Run verbosely
31
38
  -h, --help Show this message
32
39
 
40
+ ## Example reports
41
+
42
+ ![](http://cl.ly/image/261J1U04121D/team.png)
43
+
44
+ ![](http://cl.ly/image/2X3b2k3V2Q3b/peruser.png)
45
+
46
+ ![](http://cl.ly/image/3k0d0P1E3I1o/latency.png)
47
+
33
48
  ## Contributing
34
49
 
35
50
  1. Fork it
@@ -14,7 +14,7 @@ require 'git_heroes/logger'
14
14
  Dotenv.load
15
15
 
16
16
  OPTIONS = {
17
- path: 'report.csv',
17
+ path: 'report',
18
18
  verbose: false,
19
19
  token: ENV['GITHUB_TOKEN'],
20
20
  weeks: 12
@@ -62,4 +62,5 @@ end
62
62
  client = GitHeroes::Connection.new(token: OPTIONS[:token])
63
63
  engine = GitHeroes::Engine.new(client:client, org:OPTIONS[:org], weeks:OPTIONS[:weeks])
64
64
  engine.run
65
- engine.export(OPTIONS[:path])
65
+ engine.export("%s-points.csv" % OPTIONS[:path])
66
+ engine.export_durations("%s-timing.csv" % OPTIONS[:path])
@@ -10,8 +10,11 @@ class GitHeroes::Engine
10
10
  def initialize(client:nil, org:nil, weeks:nil)
11
11
  @client = client
12
12
  @organisation = org
13
+
14
+ # output/calculated fields
13
15
  @data = {}
14
16
  @users = Set.new
17
+ @durations = []
15
18
 
16
19
  @end_time = Time.now.beginning_of_week
17
20
  week_count = weeks
@@ -32,7 +35,7 @@ class GitHeroes::Engine
32
35
 
33
36
  def export(path)
34
37
  CSV.open(path, 'w') do |csv|
35
- weeks = @weeks.sort
38
+ weeks = @weeks.sort.reverse
36
39
  weeks_keys = weeks.map { |w| w.week_key }
37
40
  header = %w(login) + weeks.map { |w| w.strftime('%Y.%W (%b %d)') }
38
41
  csv << header
@@ -46,6 +49,19 @@ class GitHeroes::Engine
46
49
  end
47
50
  end
48
51
 
52
+ def export_durations(path)
53
+ CSV.open(path, 'w') do |csv|
54
+ csv << %w(login week duration)
55
+ @durations.each do |login, week, duration|
56
+ csv << [
57
+ login,
58
+ week.strftime('%Y.%W (%b %d)'),
59
+ duration / 86400
60
+ ]
61
+ end
62
+ end
63
+ end
64
+
49
65
 
50
66
  private
51
67
 
@@ -70,6 +86,12 @@ class GitHeroes::Engine
70
86
  if pull_request.merged_by
71
87
  give_points(:merge, pull_request.merged_by.login, pull_request.merged_at)
72
88
  end
89
+
90
+ if pull_request.merged_at
91
+ record_duration(pull_request.merged_at - pull_request.created_at,
92
+ pull_request.user.login,
93
+ pull_request.merged_at)
94
+ end
73
95
  end
74
96
 
75
97
 
@@ -82,6 +104,11 @@ class GitHeroes::Engine
82
104
  @data[user][week_key] += POINTS[kind]
83
105
  end
84
106
 
107
+ def record_duration(duration, user, timestamp)
108
+ return unless @start_time < timestamp && timestamp < @end_time
109
+ @durations << [user, timestamp, duration]
110
+ end
111
+
85
112
 
86
113
  def each_comment(pull_request, get_options)
87
114
  # comments on PR itself
@@ -119,11 +146,16 @@ class GitHeroes::Engine
119
146
  get_options[:headers] = { 'X-Force-Cache' => '1' }
120
147
  end
121
148
 
122
- pull_request = @client.request(:get, pull_request.rels[:self].href, get_options)
149
+ begin
150
+ pull_request = @client.request(:get, pull_request.rels[:self].href, get_options)
151
+ rescue Octokit::InternalServerError => e
152
+ $stderr.puts "skipping PR #{pull_request.inspect}"
153
+ next
154
+ end
123
155
 
124
156
  yield pull_request, get_options
125
157
  end
126
158
  end
127
159
  end
128
160
  end
129
- end
161
+ end
@@ -1,3 +1,3 @@
1
1
  module GitHeroes
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-heroes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-10 00:00:00.000000000 Z
11
+ date: 2014-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -147,6 +147,7 @@ files:
147
147
  - .gitignore
148
148
  - .ruby-version
149
149
  - Gemfile
150
+ - Gemfile.lock
150
151
  - LICENSE.txt
151
152
  - README.md
152
153
  - Rakefile
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
183
  version: '0'
183
184
  requirements: []
184
185
  rubyforge_project:
185
- rubygems_version: 2.0.3
186
+ rubygems_version: 2.0.14
186
187
  signing_key:
187
188
  specification_version: 4
188
189
  summary: Leaderboard of your team's Github activity