Class: Fief::Issues

Inherits:
Object
  • Object
show all
Defined in:
lib/fief/metrics/issues.rb

Overview

Issues in GitHub repo.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2023 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(api, repo, opts) ⇒ Issues

Returns a new instance of Issues.



26
27
28
29
30
# File 'lib/fief/metrics/issues.rb', line 26

def initialize(api, repo, opts)
  @api = api
  @repo = repo
  @opts = opts
end

Instance Method Details

#take(loog) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fief/metrics/issues.rb', line 32

def take(loog)
  json = @api.list_issues(@repo, state: 'open')
  json.select! { |i| i[:pull_request].nil? }
  total = json.count
  loog.debug("Found #{total} open issues in #{@repo}")
  old = 0
  older = 0
  json.each do |issue|
    num = issue[:number]
    data = @api.issue(@repo, num)
    if data[:created_at] < Time.now - (60 * 60 * 24 * old_days)
      loog.debug("Issue #{@repo}/##{num} is old")
      old += 1
    end
    if data[:created_at] < Time.now - (60 * 60 * 24 * older_days)
      loog.debug("Issue #{@repo}/##{num} is very old")
      older += 1
    end
  end
  [
    {
      title: 'Issues',
      value: total,
      alert: false,
      legend: 'сurrently unresolved issues'
    },
    {
      title: 'Issues+',
      value: old,
      alert: older > total * 0.4,
      legend: "issues unresolved for more than #{old_days} days"
    },
    {
      title: 'Issues++',
      value: older,
      alert: older > total * 0.4,
      legend: "issues unresolved for more than #{older_days} days"
    }
  ]
end