@@ -94,107 +94,31 private | |||||
94 | end |
|
94 | end | |
95 |
|
95 | |||
96 | def issues_by_tracker |
|
96 | def issues_by_tracker | |
97 | @issues_by_tracker ||= |
|
97 | @issues_by_tracker ||= Issue.by_tracker(@project) | |
98 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
|||
99 | s.is_closed as closed, |
|
|||
100 | t.id as tracker_id, |
|
|||
101 | count(i.id) as total |
|
|||
102 | from |
|
|||
103 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t |
|
|||
104 | where |
|
|||
105 | i.status_id=s.id |
|
|||
106 | and i.tracker_id=t.id |
|
|||
107 | and i.project_id=#{@project.id} |
|
|||
108 | group by s.id, s.is_closed, t.id") |
|
|||
109 | end |
|
98 | end | |
110 |
|
99 | |||
111 | def issues_by_version |
|
100 | def issues_by_version | |
112 | @issues_by_version ||= |
|
101 | @issues_by_version ||= Issue.by_version(@project) | |
113 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
|||
114 | s.is_closed as closed, |
|
|||
115 | v.id as fixed_version_id, |
|
|||
116 | count(i.id) as total |
|
|||
117 | from |
|
|||
118 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Version.table_name} v |
|
|||
119 | where |
|
|||
120 | i.status_id=s.id |
|
|||
121 | and i.fixed_version_id=v.id |
|
|||
122 | and i.project_id=#{@project.id} |
|
|||
123 | group by s.id, s.is_closed, v.id") |
|
|||
124 | end |
|
102 | end | |
125 |
|
103 | |||
126 | def issues_by_priority |
|
104 | def issues_by_priority | |
127 | @issues_by_priority ||= |
|
105 | @issues_by_priority ||= Issue.by_priority(@project) | |
128 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
|||
129 | s.is_closed as closed, |
|
|||
130 | p.id as priority_id, |
|
|||
131 | count(i.id) as total |
|
|||
132 | from |
|
|||
133 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssuePriority.table_name} p |
|
|||
134 | where |
|
|||
135 | i.status_id=s.id |
|
|||
136 | and i.priority_id=p.id |
|
|||
137 | and i.project_id=#{@project.id} |
|
|||
138 | group by s.id, s.is_closed, p.id") |
|
|||
139 | end |
|
106 | end | |
140 |
|
107 | |||
141 | def issues_by_category |
|
108 | def issues_by_category | |
142 | @issues_by_category ||= |
|
109 | @issues_by_category ||= Issue.by_category(@project) | |
143 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
|||
144 | s.is_closed as closed, |
|
|||
145 | c.id as category_id, |
|
|||
146 | count(i.id) as total |
|
|||
147 | from |
|
|||
148 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c |
|
|||
149 | where |
|
|||
150 | i.status_id=s.id |
|
|||
151 | and i.category_id=c.id |
|
|||
152 | and i.project_id=#{@project.id} |
|
|||
153 | group by s.id, s.is_closed, c.id") |
|
|||
154 | end |
|
110 | end | |
155 |
|
111 | |||
156 | def issues_by_assigned_to |
|
112 | def issues_by_assigned_to | |
157 | @issues_by_assigned_to ||= |
|
113 | @issues_by_assigned_to ||= Issue.by_assigned_to(@project) | |
158 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
|||
159 | s.is_closed as closed, |
|
|||
160 | a.id as assigned_to_id, |
|
|||
161 | count(i.id) as total |
|
|||
162 | from |
|
|||
163 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a |
|
|||
164 | where |
|
|||
165 | i.status_id=s.id |
|
|||
166 | and i.assigned_to_id=a.id |
|
|||
167 | and i.project_id=#{@project.id} |
|
|||
168 | group by s.id, s.is_closed, a.id") |
|
|||
169 | end |
|
114 | end | |
170 |
|
115 | |||
171 | def issues_by_author |
|
116 | def issues_by_author | |
172 | @issues_by_author ||= |
|
117 | @issues_by_author ||= Issue.by_author(@project) | |
173 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
|||
174 | s.is_closed as closed, |
|
|||
175 | a.id as author_id, |
|
|||
176 | count(i.id) as total |
|
|||
177 | from |
|
|||
178 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a |
|
|||
179 | where |
|
|||
180 | i.status_id=s.id |
|
|||
181 | and i.author_id=a.id |
|
|||
182 | and i.project_id=#{@project.id} |
|
|||
183 | group by s.id, s.is_closed, a.id") |
|
|||
184 | end |
|
118 | end | |
185 |
|
119 | |||
186 | def issues_by_subproject |
|
120 | def issues_by_subproject | |
187 | @issues_by_subproject ||= |
|
121 | @issues_by_subproject ||= Issue.by_subproject(@project) | |
188 | ActiveRecord::Base.connection.select_all("select s.id as status_id, |
|
|||
189 | s.is_closed as closed, |
|
|||
190 | i.project_id as project_id, |
|
|||
191 | count(i.id) as total |
|
|||
192 | from |
|
|||
193 | #{Issue.table_name} i, #{IssueStatus.table_name} s |
|
|||
194 | where |
|
|||
195 | i.status_id=s.id |
|
|||
196 | and i.project_id IN (#{@project.descendants.active.collect{|p| p.id}.join(',')}) |
|
|||
197 | group by s.id, s.is_closed, i.project_id") if @project.descendants.active.any? |
|
|||
198 | @issues_by_subproject ||= [] |
|
122 | @issues_by_subproject ||= [] | |
199 | end |
|
123 | end | |
200 | end |
|
124 | end |
@@ -414,6 +414,106 class Issue < ActiveRecord::Base | |||||
414 | Issue.update_versions(["#{Version.table_name}.project_id IN (?) OR #{Issue.table_name}.project_id IN (?)", moved_project_ids, moved_project_ids]) |
|
414 | Issue.update_versions(["#{Version.table_name}.project_id IN (?) OR #{Issue.table_name}.project_id IN (?)", moved_project_ids, moved_project_ids]) | |
415 | end |
|
415 | end | |
416 |
|
416 | |||
|
417 | # Extracted from the ReportsController. | |||
|
418 | # TODO: refactor into a common factory or named scopes | |||
|
419 | def self.by_tracker(project) | |||
|
420 | ActiveRecord::Base.connection.select_all("select s.id as status_id, | |||
|
421 | s.is_closed as closed, | |||
|
422 | t.id as tracker_id, | |||
|
423 | count(i.id) as total | |||
|
424 | from | |||
|
425 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t | |||
|
426 | where | |||
|
427 | i.status_id=s.id | |||
|
428 | and i.tracker_id=t.id | |||
|
429 | and i.project_id=#{project.id} | |||
|
430 | group by s.id, s.is_closed, t.id") | |||
|
431 | end | |||
|
432 | ||||
|
433 | def self.by_version(project) | |||
|
434 | ActiveRecord::Base.connection.select_all("select s.id as status_id, | |||
|
435 | s.is_closed as closed, | |||
|
436 | v.id as fixed_version_id, | |||
|
437 | count(i.id) as total | |||
|
438 | from | |||
|
439 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Version.table_name} v | |||
|
440 | where | |||
|
441 | i.status_id=s.id | |||
|
442 | and i.fixed_version_id=v.id | |||
|
443 | and i.project_id=#{project.id} | |||
|
444 | group by s.id, s.is_closed, v.id") | |||
|
445 | end | |||
|
446 | ||||
|
447 | def self.by_priority(project) | |||
|
448 | ActiveRecord::Base.connection.select_all("select s.id as status_id, | |||
|
449 | s.is_closed as closed, | |||
|
450 | p.id as priority_id, | |||
|
451 | count(i.id) as total | |||
|
452 | from | |||
|
453 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssuePriority.table_name} p | |||
|
454 | where | |||
|
455 | i.status_id=s.id | |||
|
456 | and i.priority_id=p.id | |||
|
457 | and i.project_id=#{project.id} | |||
|
458 | group by s.id, s.is_closed, p.id") | |||
|
459 | end | |||
|
460 | ||||
|
461 | def self.by_category(project) | |||
|
462 | ActiveRecord::Base.connection.select_all("select s.id as status_id, | |||
|
463 | s.is_closed as closed, | |||
|
464 | c.id as category_id, | |||
|
465 | count(i.id) as total | |||
|
466 | from | |||
|
467 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c | |||
|
468 | where | |||
|
469 | i.status_id=s.id | |||
|
470 | and i.category_id=c.id | |||
|
471 | and i.project_id=#{project.id} | |||
|
472 | group by s.id, s.is_closed, c.id") | |||
|
473 | end | |||
|
474 | ||||
|
475 | def self.by_assigned_to(project) | |||
|
476 | ActiveRecord::Base.connection.select_all("select s.id as status_id, | |||
|
477 | s.is_closed as closed, | |||
|
478 | a.id as assigned_to_id, | |||
|
479 | count(i.id) as total | |||
|
480 | from | |||
|
481 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a | |||
|
482 | where | |||
|
483 | i.status_id=s.id | |||
|
484 | and i.assigned_to_id=a.id | |||
|
485 | and i.project_id=#{project.id} | |||
|
486 | group by s.id, s.is_closed, a.id") | |||
|
487 | end | |||
|
488 | ||||
|
489 | def self.by_author(project) | |||
|
490 | ActiveRecord::Base.connection.select_all("select s.id as status_id, | |||
|
491 | s.is_closed as closed, | |||
|
492 | a.id as author_id, | |||
|
493 | count(i.id) as total | |||
|
494 | from | |||
|
495 | #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a | |||
|
496 | where | |||
|
497 | i.status_id=s.id | |||
|
498 | and i.author_id=a.id | |||
|
499 | and i.project_id=#{project.id} | |||
|
500 | group by s.id, s.is_closed, a.id") | |||
|
501 | end | |||
|
502 | ||||
|
503 | def self.by_subproject(project) | |||
|
504 | ActiveRecord::Base.connection.select_all("select s.id as status_id, | |||
|
505 | s.is_closed as closed, | |||
|
506 | i.project_id as project_id, | |||
|
507 | count(i.id) as total | |||
|
508 | from | |||
|
509 | #{Issue.table_name} i, #{IssueStatus.table_name} s | |||
|
510 | where | |||
|
511 | i.status_id=s.id | |||
|
512 | and i.project_id IN (#{project.descendants.active.collect{|p| p.id}.join(',')}) | |||
|
513 | group by s.id, s.is_closed, i.project_id") if project.descendants.active.any? | |||
|
514 | end | |||
|
515 | # End ReportsController extraction | |||
|
516 | ||||
417 | private |
|
517 | private | |
418 |
|
518 | |||
419 | # Update issues so their versions are not pointing to a |
|
519 | # Update issues so their versions are not pointing to a |
General Comments 0
You need to be logged in to leave comments.
Login now