@@ -85,42 +85,6 class ReportsController < ApplicationController | |||||
85 | end |
|
85 | end | |
86 | end |
|
86 | end | |
87 |
|
87 | |||
88 | def delays |
|
|||
89 | @trackers = Tracker.find(:all) |
|
|||
90 | if request.get? |
|
|||
91 | @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } |
|
|||
92 | else |
|
|||
93 | @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array |
|
|||
94 | end |
|
|||
95 | @selected_tracker_ids ||= [] |
|
|||
96 | @raw = |
|
|||
97 | ActiveRecord::Base.connection.select_all("SELECT datediff( a.created_on, b.created_on ) as delay, count(a.id) as total |
|
|||
98 | FROM issue_histories a, issue_histories b, issues i |
|
|||
99 | WHERE a.status_id =5 |
|
|||
100 | AND a.issue_id = b.issue_id |
|
|||
101 | AND a.issue_id = i.id |
|
|||
102 | AND i.tracker_id in (#{@selected_tracker_ids.join(',')}) |
|
|||
103 | AND b.id = ( |
|
|||
104 | SELECT min( c.id ) |
|
|||
105 | FROM issue_histories c |
|
|||
106 | WHERE b.issue_id = c.issue_id ) |
|
|||
107 | GROUP BY delay") unless @selected_tracker_ids.empty? |
|
|||
108 | @raw ||=[] |
|
|||
109 |
|
||||
110 | @x_from = 0 |
|
|||
111 | @x_to = 0 |
|
|||
112 | @y_from = 0 |
|
|||
113 | @y_to = 0 |
|
|||
114 | @sum_total = 0 |
|
|||
115 | @sum_delay = 0 |
|
|||
116 | @raw.each do |r| |
|
|||
117 | @x_to = [r['delay'].to_i, @x_to].max |
|
|||
118 | @y_to = [r['total'].to_i, @y_to].max |
|
|||
119 | @sum_total = @sum_total + r['total'].to_i |
|
|||
120 | @sum_delay = @sum_delay + r['total'].to_i * r['delay'].to_i |
|
|||
121 | end |
|
|||
122 | end |
|
|||
123 |
|
||||
124 | private |
|
88 | private | |
125 | # Find project of id params[:id] |
|
89 | # Find project of id params[:id] | |
126 | def find_project |
|
90 | def find_project |
General Comments 0
You need to be logged in to leave comments.
Login now