issue-by_subproject.patch

Igor Zubkov, 2011-09-22 12:24

Download (2.38 KB)

View differences:

app/models/issue.rb (working copy)
711 711
  end
712 712

  
713 713
  def self.by_subproject(project)
714
    ActiveRecord::Base.connection.select_all("select    s.id as status_id, 
715
                                                s.is_closed as closed, 
716
                                                #{Issue.table_name}.project_id as project_id,
717
                                                count(#{Issue.table_name}.id) as total 
718
                                              from 
714
    ActiveRecord::Base.connection.select_all("SELECT s.id AS status_id,
715
                                                s.is_closed AS closed,
716
                                                #{Issue.table_name}.project_id AS project_id,
717
                                                COUNT(#{Issue.table_name}.id) AS total
718
                                              FROM
719 719
                                                #{Issue.table_name}, #{Project.table_name}, #{IssueStatus.table_name} s
720
                                              where 
721
                                                #{Issue.table_name}.status_id=s.id
722
                                                and #{Issue.table_name}.project_id = #{Project.table_name}.id
723
                                                and #{visible_condition(User.current, :project => project, :with_subprojects => true)}
724
                                                and #{Issue.table_name}.project_id <> #{project.id}
725
                                              group by s.id, s.is_closed, #{Issue.table_name}.project_id") if project.descendants.active.any?
720
                                              WHERE
721
                                                #{Issue.table_name}.status_id = s.id
722
                                                AND #{Issue.table_name}.project_id = #{Project.table_name}.id
723
                                                AND #{visible_condition(User.current, :project => project, :with_subprojects => true)}
724
                                                AND #{Issue.table_name}.project_id <> #{project.id}
725
                                              GROUP BY s.id, s.is_closed, #{Issue.table_name}.project_id") if project.descendants.active.any?
726 726
  end
727 727
  # End ReportsController extraction
728 728