Class: Inq::Sources::Github::Issues
Overview
Fetches various information about GitHub Issues.
Direct Known Subclasses
Pulls
Instance Attribute Summary collapse
Instance Method Summary
collapse
#average_age_for, #newest_for, #obj_to_array_of_hashes, #oldest_for, #sort_iops_by_created_at
#date_ge, #date_le
Constructor Details
#initialize(config, start_date, end_date, cache) ⇒ Issues
Returns a new instance of Issues.
25
26
27
28
29
30
31
32
|
# File 'lib/inq/sources/github/issues.rb', line 25
def initialize(config, start_date, end_date, cache)
@config = config
@cache = cache
@repository = config["repository"]
raise "#{self.class}.new() got nil repository." if @repository.nil?
@start_date = start_date
@end_date = end_date
end
|
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
19
20
21
|
# File 'lib/inq/sources/github/issues.rb', line 19
def cache
@cache
end
|
#config ⇒ Object
Returns the value of attribute config.
19
20
21
|
# File 'lib/inq/sources/github/issues.rb', line 19
def config
@config
end
|
#end_date ⇒ Object
Returns the value of attribute end_date.
19
20
21
|
# File 'lib/inq/sources/github/issues.rb', line 19
def end_date
@end_date
end
|
#start_date ⇒ Object
Returns the value of attribute start_date.
19
20
21
|
# File 'lib/inq/sources/github/issues.rb', line 19
def start_date
@start_date
end
|
Instance Method Details
#average_age ⇒ Object
49
50
51
|
# File 'lib/inq/sources/github/issues.rb', line 49
def average_age
average_age_for(data)
end
|
#newest ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/inq/sources/github/issues.rb', line 62
def newest
result = newest_for(data)
return {} if result.nil?
result["date"] = pretty_date(result["createdAt"])
result
end
|
#oldest ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/inq/sources/github/issues.rb', line 53
def oldest
result = oldest_for(data)
return {} if result.nil?
result["date"] = pretty_date(result["createdAt"])
result
end
|
#pretty_type ⇒ Object
103
104
105
|
# File 'lib/inq/sources/github/issues.rb', line 103
def pretty_type
"issue"
end
|
#summary ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/inq/sources/github/issues.rb', line 71
def summary
number_open = to_a.length
pretty_number = pluralize(pretty_type, number_open, zero_is_no: false)
was_were = (number_open == 1) ? "was" : "were"
"<p>A total of <a href=\"#{url}\">#{pretty_number}</a> #{was_were} opened during this period.</p>"
end
|
#to_a ⇒ Object
95
96
97
|
# File 'lib/inq/sources/github/issues.rb', line 95
def to_a
obj_to_array_of_hashes(data)
end
|
#to_html ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/inq/sources/github/issues.rb', line 79
def to_html
return summary if to_a.empty?
Inq::Template.apply("issues_or_pulls_partial.html", {
summary: summary,
average_age: average_age,
pretty_type: pretty_type,
oldest_link: oldest["url"],
oldest_date: oldest["date"],
newest_link: newest["url"],
newest_date: newest["date"],
})
end
|
#type ⇒ Object
99
100
101
|
# File 'lib/inq/sources/github/issues.rb', line 99
def type
singular_type + "s"
end
|
#url(values = {}) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/inq/sources/github/issues.rb', line 34
def url(values = {})
defaults = {
"is" => singular_type,
"created" => "#{@start_date}..#{@end_date}",
}
values = defaults.merge(values)
raw_query = values.map { |k, v|
[k, v].join(":")
}.join(" ")
query = CGI.escape(raw_query)
"https://github.com/#{@repository}/#{url_suffix}?q=#{query}"
end
|