cobench 0.0.41 → 0.0.43

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: d7f07c51df659224ffeaa6c55023f000f8af7cfe12fb8f7a24fbd3cf69dc3438
4
- data.tar.gz: eea449cfe913d636469f3f7db54573cbd21ea8a9319ee09e1b83c30c5e52f853
3
+ metadata.gz: cabe10e0f4143687f43ae2f9114906197d14b2cf47f29111bdc1d974e1615dc9
4
+ data.tar.gz: 2d7c43fb9702ee84a2844995724f05193cf816414cc027cbeb761f2b34f84443
5
5
  SHA512:
6
- metadata.gz: 9b0ebc5915261c0fe6f4fb53eb7f710cc14feb7339d42bcebc3857c5a10ab59c6bd1fb510f2a3b6726d175302483b26e416d38fa426f2f62d0b461ef85a04ff0
7
- data.tar.gz: ae97ec2ae2f982e70a5c59a80579361921a1ca15f391eedfef9bc824ac56443cacf2a84c6a0196667946ed893d1892936f9e163c91d29d27eeeb94ff63293fd4
6
+ metadata.gz: 7f5f3e6eda6a79e35aca42a7fd4439bd98cdac809b867931c25c8d79ce8968286ed9fdb00d2bad764d01aa419a0eb5c4ca3aeb1e66c99b69f256546cf98bc584
7
+ data.tar.gz: 4075b13331760eff6b869bddcc4e095294d99aa930ad322147588a0c049bc08603197ae5d325589a2c3706f0eb7e1451574efc1f190b99ea5c7c21ce596f6682
data/assets/index.xsl CHANGED
@@ -145,6 +145,7 @@ SOFTWARE.
145
145
  <xsl:text>issues</xsl:text>
146
146
  </a>
147
147
  <xsl:text>. </xsl:text>
148
+ <xsl:text>"LcP" is an average lifecycle of a pull request in hours. </xsl:text>
148
149
  <xsl:text>"Msgs" is the total number of messages posted in pull requests where the user was a reviewer. </xsl:text>
149
150
  <xsl:text>"Pulls" is the total number of </xsl:text>
150
151
  <a href="https://docs.github.com/en/pull-requests">
data/bin/cobench CHANGED
@@ -82,7 +82,8 @@ end
82
82
 
83
83
  def zero?(ms)
84
84
  return true if ms.nil?
85
- return true unless ms.key?(:actual)
85
+ return true if ms[:total] == 0
86
+ return true if ms.key?(:actual) && ms[:actual] == 0
86
87
  false
87
88
  end
88
89
 
@@ -166,7 +167,8 @@ def build_xml(opts, loog)
166
167
  'Issues' => 50,
167
168
  'Commits' => 5,
168
169
  'Reviews' => 150,
169
- 'Msgs' => 5
170
+ 'Msgs' => 5,
171
+ 'LcP' => 0,
170
172
  }
171
173
  data.each do |u, ms|
172
174
  score = ms.map do |t, h|
@@ -19,6 +19,7 @@
19
19
  # SOFTWARE.
20
20
 
21
21
  require 'iri'
22
+ require 'time'
22
23
  require_relative '../match'
23
24
 
24
25
  # Pulls in GitHub API.
@@ -39,12 +40,14 @@ class Cobench::Pulls
39
40
  loog.debug("Found #{json.total_count} pull requests")
40
41
  hoc = 0
41
42
  orgs = []
43
+ lcps = []
42
44
  total = json.items.count do |p|
43
45
  pr = p.pull_request.url.split('/')[-1]
44
46
  repo = p.repository_url.split('/')[-2..-1].join('/')
45
47
  next unless Cobench::Match.new(@opts, loog).matches?(repo)
46
48
  orgs << p.repository_url.split('/')[-2]
47
49
  pr_json = @api.pull_request(repo, pr)
50
+ lcps << (pr_json[:merged_at] - pr_json[:created_at])
48
51
  hocs = pr_json.additions + pr_json.deletions
49
52
  hoc += hocs
50
53
  loog.debug("Including #{repo}##{pr} with #{hocs}")
@@ -60,10 +63,13 @@ class Cobench::Pulls
60
63
  total: total,
61
64
  href: Iri.new('https://github.com/search').add(q: q)
62
65
  },
66
+ {
67
+ title: 'LcP',
68
+ total: lcps.size.zero? ? 0 : ((lcps.inject(&:+) / lcps.size) / (60 * 60)).to_i
69
+ },
63
70
  {
64
71
  title: 'HoC',
65
- total: hoc,
66
- href: ''
72
+ total: hoc
67
73
  }
68
74
  ]
69
75
  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.41'.freeze
26
+ VERSION = '0.0.43'.freeze
27
27
  end
@@ -0,0 +1,41 @@
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/pulls'
25
+
26
+ # Test for Pulls.
27
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
+ # Copyright:: Copyright (c) 2022 Yegor Bugayenko
29
+ # License:: MIT
30
+ class TestPulls < Minitest::Test
31
+ def test_real
32
+ api = Octokit::Client.new
33
+ m = Cobench::Pulls.new(api, 'yegor256', { days: 5 })
34
+ ms = m.take(Loog::VERBOSE)
35
+ assert !ms.empty?
36
+ p ms
37
+ rescue Octokit::TooManyRequests => e
38
+ puts e.message
39
+ skip
40
+ end
41
+ 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.41
4
+ version: 0.0.43
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-27 00:00:00.000000000 Z
11
+ date: 2022-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -273,6 +273,7 @@ files:
273
273
  - lib/cobench/version.rb
274
274
  - logo.svg
275
275
  - renovate.json
276
+ - test/metrics/test_pulls.rb
276
277
  - test/metrics/test_reviews.rb
277
278
  - test/test__helper.rb
278
279
  - test/test_mask.rb