Skip to content

Commit

Permalink
#135: calculate lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 22, 2024
1 parent 886e028 commit 55526e3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
17 changes: 17 additions & 0 deletions judges/quality-of-service/quality-of-service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,20 @@
f = Fbe.fb.insert
f.what = $judge
f.when = Time.now

def lifetime(days, type)
ages = []
Fbe.unmask_repos.each do |repo|
q = "repo:#{repo} type:#{type} closed:>#{(Time.now - (days * 24 * 60 * 60)).utc.iso8601[0..10]}"
ages += Fbe.octo.search_issues(q)[:items].map do |json|
next if json[:closed_at].nil?
next if json[:created_at].nil?
json[:closed_at] - json[:created_at]
end
end
ages.compact!
ages.empty? ? 0 : ages.inject(&:+) / ages.size
end

f.average_issue_lifetime = lifetime(28, 'issue')
f.average_pull_lifetime = lifetime(28, 'pr')
34 changes: 34 additions & 0 deletions judges/quality-of-service/simple-collect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# MIT License
#
# Copyright (c) 2024 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
options:
TODAY: 2024-03-03T00:00:00
repositories: yegor256/judges
testing: true
input:
-
what: quality-of-service
when: 2024-01-01T00:00:00
expected:
- /fb[count(f)=2]
- /fb/f[average_issue_lifetime=0]
- /fb/f[average_pull_lifetime=0]

0 comments on commit 55526e3

Please sign in to comment.