cobench 0.0.33 → 0.0.36

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: e826b27c5e0587f100676d206c255ab1a49dd031218a983949641434d742642b
4
- data.tar.gz: 3f940d517efae58c02800681ce181fce837ea4d33bf6a6698833f808856bfa0a
3
+ metadata.gz: 96be8a2561b910ee67b624e728bf639f5c232ad76fb7773cb8575cb9e6581882
4
+ data.tar.gz: 19050e7f9ee743cab744e380abd704e16f47ee7f6aa21f31553f53522d56410c
5
5
  SHA512:
6
- metadata.gz: 2f89fe625b2e9ad37e2f94ec370af8e45552dfcce768a1dea6b583714994ecd119493d7f65113c5cc8262f7e81ed86951ce49f06970929b0b611a7225ce98186
7
- data.tar.gz: cb4a616c54c4fba0109a6bd36592f2377896793de5ff05b7ba1ea228d77b89eeccf39962d5ba09af5d94168fc25e103d4809344c1b747a9a96d673305779fc41
6
+ metadata.gz: 5589979370cf2ef019c57ecaf942ba1fab9992a5bc75736e4f681728bd6695864b8135475501ed0ee7e73fc68da8d3c1105ed3dea31eee283a9fdd2c3d1c1ab9
7
+ data.tar.gz: 852309017ddf77403244d73391d6b6c8b01fd11e25f9d328f0ff98283210d6d011e1d24f6fcfc89e3a84706b7b16c7049351b880b7b822b8dbc7eed6859008a7
data/assets/index.xsl CHANGED
@@ -98,6 +98,16 @@ SOFTWARE.
98
98
  <xsl:text> to see all.</xsl:text>
99
99
  </p>
100
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>
101
111
  <colgroup>
102
112
  <col/>
103
113
  <col style="width: 2.5em;"/>
@@ -144,6 +154,7 @@ SOFTWARE.
144
154
  <xsl:text>issues</xsl:text>
145
155
  </a>
146
156
  <xsl:text>. </xsl:text>
157
+ <xsl:text>"Msgs" is the total number of messages posted as a reviewer in pull requests. </xsl:text>
147
158
  <xsl:text>"Pulls" is the total number of </xsl:text>
148
159
  <a href="https://docs.github.com/en/pull-requests">
149
160
  <xsl:text>pull requests</xsl:text>
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,13 +37,20 @@ class Cobench::Issues
37
37
  q = "in:comments type:issue author:#{@user} created:>#{from}"
38
38
  json = @api.search_issues(q)
39
39
  loog.debug("Found #{json.total_count} issues")
40
+ orgs = []
40
41
  total = json.items.count do |p|
41
42
  pr = p.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
45
  loog.debug("Including #{repo}#{pr}")
46
+ orgs << p.repository_url.split('/')[-2]
45
47
  end
46
48
  [
49
+ {
50
+ meta: true,
51
+ title: 'Orgs',
52
+ list: orgs
53
+ },
47
54
  {
48
55
  title: 'Issues',
49
56
  total: total,
@@ -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.33'.freeze
26
+ VERSION = '0.0.36'.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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-04 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -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