cobench 0.0.32 → 0.0.35

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
  SHA256:
3
- metadata.gz: 862a9495f75a20749f29e93af9d8019e0b388c1f1628bc7d59db8193d1473b21
4
- data.tar.gz: 95772672a309295380adeb8a8f624edbf2353c2a96be28e8b7fc3f2e65cf31b5
3
+ metadata.gz: fdd68553eb250f70a8b28b55881595a6ca920b35451a76e7eaaefe963e5c81f4
4
+ data.tar.gz: bd69957900879988ccbc4194959d1ca27c55452a3f33f9a51bbcba4fe528e5da
5
5
  SHA512:
6
- metadata.gz: 48710b9f7e18c421b95abe5efec899d7641fb3fd80fa706257cbd0d7ed3c752ab00e6d3a40372afe47ce083b8dc319c9190b242e95a81561e60f5cee82a078f6
7
- data.tar.gz: 4a06820fe76ad19d10c5919b5fb8e23a3ab314fb5b4101079e740f706b0b190a105c247a4932617421b012ce7cc86a03750e4efbd2d5322b9710fa87dd5f9104
6
+ metadata.gz: f617125d6f05b54e008170fd5fa53fc5623a16a861bd044ab0c31421a7e6054a601f8fc0cfa3a68dc10c3a01b35a0393942485d69729d34b7f570399981f835d
7
+ data.tar.gz: 7579e8f69a4bb6d85d1b5a0aebce2223b4f95881f6a91122869f3b1b3a86b069a01be99725af4ffc960d56a9e416664ec856d0d6f3e38beec61aff579508af43
data/assets/index.xsl CHANGED
@@ -58,7 +58,8 @@ SOFTWARE.
58
58
  });
59
59
  </script>
60
60
  <style>
61
- td, th { font-family: monospace; font-size: 18px; }
61
+ td, th { font-family: monospace; font-size: 18px; line-height: 1em; }
62
+ td.top { vertical-align: middle; }
62
63
  .num { text-align: right; }
63
64
  .left { border-bottom: 0; }
64
65
  section { width: auto; }
@@ -97,6 +98,16 @@ SOFTWARE.
97
98
  <xsl:text> to see all.</xsl:text>
98
99
  </p>
99
100
  <table id="metrics">
101
+ <xsl:attribute name="data-sortlist">
102
+ <xsl:text>[[</xsl:text>
103
+ <xsl:for-each select="cobench/titles/title">
104
+ <xsl:sort select="."/>
105
+ <xsl:if test=". = 'Score'">
106
+ <xsl:value-of select="position() + 2"/>
107
+ </xsl:if>
108
+ </xsl:for-each>
109
+ <xsl:text>,1]]</xsl:text>
110
+ </xsl:attribute>
100
111
  <colgroup>
101
112
  <col/>
102
113
  <col style="width: 2.5em;"/>
@@ -143,6 +154,7 @@ SOFTWARE.
143
154
  <xsl:text>issues</xsl:text>
144
155
  </a>
145
156
  <xsl:text>. </xsl:text>
157
+ <xsl:text>"Msgs" is the total number of messages posted as a reviewer in pull requests. </xsl:text>
146
158
  <xsl:text>"Pulls" is the total number of </xsl:text>
147
159
  <a href="https://docs.github.com/en/pull-requests">
148
160
  <xsl:text>pull requests</xsl:text>
@@ -265,9 +277,12 @@ SOFTWARE.
265
277
  </xsl:template>
266
278
  <xsl:template match="coder">
267
279
  <tr>
268
- <td class="num">
280
+ <td class="num top">
269
281
  <xsl:variable name="score" select="metrics/m[@id='Score']"/>
270
- <xsl:variable name="pos" select="count(/cobench/coders/coder[metrics/m[@id='Score'] &lt; $score]) + 1"/>
282
+ <xsl:variable name="pos" select="count(/cobench/coders/coder[metrics/m[@id='Score'] &gt; $score]) + 1"/>
283
+ <xsl:attribute name="title">
284
+ <xsl:value-of select="$pos"/>
285
+ </xsl:attribute>
271
286
  <xsl:if test="$pos &lt;= 8">
272
287
  <xsl:text>#</xsl:text>
273
288
  <xsl:value-of select="$pos"/>
data/bin/cobench CHANGED
@@ -80,6 +80,7 @@ def div(a, b)
80
80
  end
81
81
 
82
82
  def actual(ms)
83
+ return 0 if ms.nil?
83
84
  return ms[:actual] if ms.key?(:actual)
84
85
  ms[:total]
85
86
  end
@@ -157,7 +158,8 @@ def build_xml(opts, loog)
157
158
  'Pulls' => 250,
158
159
  'Issues' => 50,
159
160
  'Commits' => 5,
160
- 'Reviews' => 150
161
+ 'Reviews' => 150,
162
+ 'Msgs' => 5
161
163
  }
162
164
  data.each do |u, ms|
163
165
  score = ms.map do |t, h|
@@ -169,11 +171,15 @@ def build_xml(opts, loog)
169
171
  averages = {
170
172
  'HpP': {
171
173
  f: lambda { |ms| div(actual(ms['HoC']), actual(ms['Pulls'])) },
172
- title: 'HoC per Pull'
174
+ title: 'HoC per Pull Request'
173
175
  },
174
176
  'HpC': {
175
177
  f: lambda { |ms| div(actual(ms['HoC']), actual(ms['Commits'])) },
176
178
  title: 'HoC per Commit'
179
+ },
180
+ 'MpP': {
181
+ f: lambda { |ms| div(actual(ms['Msgs']), actual(ms['Pulls'])) },
182
+ title: 'Messages per Pull Request'
177
183
  }
178
184
  }
179
185
  data.each do |u, ms|
data/lib/cobench/match.rb CHANGED
@@ -31,11 +31,11 @@ class Cobench::Match
31
31
  end
32
32
 
33
33
  def matches?(repo)
34
- if !@opts[:include].empty? && @opts[:include].none? { |m| Cobench::Mask.new(m).matches?(repo) }
34
+ if @opts[:include] && !@opts[:include].empty? && @opts[:include].none? { |m| Cobench::Mask.new(m).matches?(repo) }
35
35
  @loog.debug("Excluding #{repo} due to lack of --include")
36
36
  return false
37
37
  end
38
- if @opts[:exclude].any? { |m| Cobench::Mask.new(m).matches?(repo) }
38
+ if @opts[:exclude] && @opts[:exclude].any? { |m| Cobench::Mask.new(m).matches?(repo) }
39
39
  @loog.debug("Excluding #{repo} due to --exclude")
40
40
  return false
41
41
  end
@@ -37,17 +37,25 @@ class Cobench::Reviews
37
37
  q = "reviewed-by:#{@user} merged:>#{from}"
38
38
  json = @api.search_issues(q)
39
39
  loog.debug("Found #{json.total_count} reviews")
40
+ msgs = 0
40
41
  total = json.items.count do |p|
41
42
  pr = p.pull_request.url.split('/')[-1]
42
43
  repo = p.repository_url.split('/')[-2..-1].join('/')
43
44
  next unless Cobench::Match.new(@opts, loog).matches?(repo)
44
- loog.debug("Including #{repo}##{pr} reviewed by #{@user}")
45
+ loog.debug("Including #{repo}##{pr} reviewed by @#{@user}")
46
+ posted = @api.pull_request_comments(repo, pr).count { |c| c[:user][:login].downcase == @user }
47
+ loog.debug("#{posted} messages posted by @#{@user} to #{repo}##{pr}")
48
+ msgs += posted
45
49
  end
46
50
  [
47
51
  {
48
52
  title: 'Reviews',
49
53
  total: total,
50
54
  href: Iri.new('https://github.com/search').add(q: q)
55
+ },
56
+ {
57
+ title: 'Msgs',
58
+ total: msgs
51
59
  }
52
60
  ]
53
61
  end
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2022 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Cobench
26
- VERSION = '0.0.32'.freeze
26
+ VERSION = '0.0.35'.freeze
27
27
  end
@@ -0,0 +1,37 @@
1
+ # Copyright (c) 2022 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'minitest/autorun'
22
+ require 'octokit'
23
+ require 'loog'
24
+ require_relative '../../lib/cobench/metrics/reviews'
25
+
26
+ # Test for Reviews.
27
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
+ # Copyright:: Copyright (c) 2022 Yegor Bugayenko
29
+ # License:: MIT
30
+ class TestReviews < Minitest::Test
31
+ def test_real
32
+ api = Octokit::Client.new
33
+ m = Cobench::Reviews.new(api, 'graur', { days: 2 })
34
+ ms = m.take(Loog::VERBOSE)
35
+ assert !ms.empty?
36
+ end
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.32
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -272,6 +272,7 @@ files:
272
272
  - lib/cobench/metrics/reviews.rb
273
273
  - lib/cobench/version.rb
274
274
  - logo.svg
275
+ - test/metrics/test_reviews.rb
275
276
  - test/test__helper.rb
276
277
  - test/test_mask.rb
277
278
  - test/test_match.rb