lib/fief/metrics/pulls.rb in fief-0.0.1 vs lib/fief/metrics/pulls.rb in fief-0.0.2
- old
+ new
@@ -29,14 +29,40 @@
@opts = opts
end
def take(loog)
json = @api.pull_requests(@repo, state: 'open')
- loog.debug("Found #{json.count} open pull requests in #{@repo}")
+ total = json.count
+ loog.debug("Found #{total} open pull requests in #{@repo}")
+ old = 0
+ older = 0
+ json.each do |pr|
+ num = pr[:number]
+ data = @api.pull_request(@repo, num)
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 14)
+ loog.debug("PR #{@repo}/##{num} is old")
+ old += 1
+ end
+ if data[:created_at] < Time.now - (60 * 60 * 24 * 56)
+ loog.debug("PR #{@repo}/##{num} is very old")
+ older += 1
+ end
+ end
[
{
- title: 'Open Pull Requests',
- value: json.count
+ title: 'Open PRs',
+ value: total,
+ alert: false
+ },
+ {
+ title: 'Old PRs',
+ value: old,
+ alert: older > total * 0.4
+ },
+ {
+ title: 'Older PRs',
+ value: older,
+ alert: older > total * 0.2
}
]
end
end