Class: JiraReporting::SLAReport
- Inherits:
-
Object
- Object
- JiraReporting::SLAReport
- Defined in:
- lib/jira_reporting/sla_report.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
Returns the value of attribute conn.
Class Method Summary collapse
Instance Method Summary collapse
- #custom_fields ⇒ Object
- #find_all(query, offset = 0) ⇒ Object
-
#initialize ⇒ SLAReport
constructor
A new instance of SLAReport.
- #log(str) ⇒ Object
- #prio_report(name, group) ⇒ Object
- #show_report ⇒ Object
Constructor Details
#initialize ⇒ SLAReport
Returns a new instance of SLAReport.
8 9 10 11 |
# File 'lib/jira_reporting/sla_report.rb', line 8 def initialize @conn = Connection.instance @debug = true end |
Instance Attribute Details
#conn ⇒ Object
Returns the value of attribute conn.
13 14 15 |
# File 'lib/jira_reporting/sla_report.rb', line 13 def conn @conn end |
Class Method Details
.show_report ⇒ Object
4 5 6 |
# File 'lib/jira_reporting/sla_report.rb', line 4 def self.show_report self.new.show_report end |
Instance Method Details
#custom_fields ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/jira_reporting/sla_report.rb', line 76 def custom_fields @custom_fields ||= Hash[[ [10812, "Support xt Can't Reproduce"], [10808, 'Support xt In Progress'], [10809, 'Support xt Not Accepted'], [10817, 'Support xt Requester Denied'], [10814, 'Support xt Requester Review'], [10816, 'Support xt Resolved'], [10815, 'Support xt Reverify'], [10813, 'Support xt Review'], [10810, 'Support xt Triaged'], [10811, 'Support xt Verified'], ].map{|k,v| ["customfield_#{k}", v]}] end |
#find_all(query, offset = 0) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/jira_reporting/sla_report.rb', line 40 def find_all(query, offset = 0) ask = 100 result = Jiralicious.search(query, start_at: offset, max_results: ask) issues = result.issues_raw if issues.count == ask && result.num_results > issues.count issues += find_all(query, offset + ask) end # puts "found #{issues.count}" issues end |
#log(str) ⇒ Object
15 16 17 |
# File 'lib/jira_reporting/sla_report.rb', line 15 def log(str) puts "#{Time.now} #{str}" if @debug end |
#prio_report(name, group) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/jira_reporting/sla_report.rb', line 51 def prio_report(name, group) puts "\n#{name}:" cur_week = Time.now.to_date.cweek week_groups = group.group_by{|t| t.created_at.to_date.cweek } wgs = week_groups.to_a.select{|week, set| week >= (cur_week - 27) } wgs.sort!{|a,b| a[0] <=> b[0] } puts "Week: #{wgs.map{|w,s| "%12i" % w }.join(" | ")}" o = [] wgs.each do |week, set| sla_rate = set.select{|t| t.sla_diff <= 0 }.length.to_f / set.length o << "%11.2f%" % (sla_rate*100) end puts "SLA Hit Rate: #{o.join " | "}" o = [] wgs.each do |week, set| over_under = set.map(&:sla_diff).sum o << "%12i" % over_under end puts "Over Under: #{o.join " | "}" end |
#show_report ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jira_reporting/sla_report.rb', line 19 def show_report log 'querying' #query = %q{project = "Tech Support" AND ("Support xt Can't Reproduce" > startOfDay(-7d) OR "Support xt Not Accepted" > startOfDay(-7d) OR "Support xt Resolved" > startOfDay(-7d)) AND status not in ("Not Accepted", "Can't Reproduce")} query = %q{ project = "Tech Support" AND status not in ("Not Accepted", "Can't Reproduce")} #issues = Jiralicious.search(query).issues_raw issues = find_all(query) #log 'unmapping custom fields' #unmap_custom_fields(issues.first) rept = issues.map{|i| ReportIssue.new(i, custom_fields) } prios = rept.group_by(&:priority) prio_report("P1", prios[:p1]) prio_report("P2", prios[:p2]) prio_report("P3", prios[:p3]) prio_report("P4", prios[:p4]) end |