Mercurial > hg > soundsoftware-site
comparison app/models/.svn/text-base/issue.rb.svn-base @ 23:ca82a3468d27 cannam
* Merge SVN update from default
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 24 Sep 2010 14:17:42 +0100 |
parents | 40f7cfd4df19 |
children | 94944d00e43c |
comparison
equal
deleted
inserted
replaced
21:d0cd1f6335a5 | 23:ca82a3468d27 |
---|---|
60 named_scope :visible, lambda {|*args| { :include => :project, | 60 named_scope :visible, lambda {|*args| { :include => :project, |
61 :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } } | 61 :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } } |
62 | 62 |
63 named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status | 63 named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status |
64 | 64 |
65 named_scope :recently_updated, :order => "#{self.table_name}.updated_on DESC" | 65 named_scope :recently_updated, :order => "#{Issue.table_name}.updated_on DESC" |
66 named_scope :with_limit, lambda { |limit| { :limit => limit} } | 66 named_scope :with_limit, lambda { |limit| { :limit => limit} } |
67 named_scope :on_active_project, :include => [:status, :project, :tracker], | 67 named_scope :on_active_project, :include => [:status, :project, :tracker], |
68 :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"] | 68 :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"] |
69 named_scope :for_gantt, lambda { | |
70 { | |
71 :include => [:tracker, :status, :assigned_to, :priority, :project, :fixed_version], | |
72 :order => "#{Issue.table_name}.due_date ASC, #{Issue.table_name}.start_date ASC, #{Issue.table_name}.id ASC" | |
73 } | |
74 } | |
75 | |
76 named_scope :without_version, lambda { | |
77 { | |
78 :conditions => { :fixed_version_id => nil} | |
79 } | |
80 } | |
81 | |
82 named_scope :with_query, lambda {|query| | |
83 { | |
84 :conditions => Query.merge_conditions(query.statement) | |
85 } | |
86 } | |
69 | 87 |
70 before_create :default_assign | 88 before_create :default_assign |
71 before_save :reschedule_following_issues, :close_duplicates, :update_done_ratio_from_issue_status | 89 before_save :reschedule_following_issues, :close_duplicates, :update_done_ratio_from_issue_status |
72 after_save :update_nested_set_attributes, :update_parent_attributes, :create_journal | 90 after_save :update_nested_set_attributes, :update_parent_attributes, :create_journal |
73 after_destroy :destroy_children | 91 after_destroy :destroy_children |
354 end | 372 end |
355 | 373 |
356 # Returns true if the issue is overdue | 374 # Returns true if the issue is overdue |
357 def overdue? | 375 def overdue? |
358 !due_date.nil? && (due_date < Date.today) && !status.is_closed? | 376 !due_date.nil? && (due_date < Date.today) && !status.is_closed? |
377 end | |
378 | |
379 # Is the amount of work done less than it should for the due date | |
380 def behind_schedule? | |
381 return false if start_date.nil? || due_date.nil? | |
382 done_date = start_date + ((due_date - start_date+1)* done_ratio/100).floor | |
383 return done_date <= Date.today | |
384 end | |
385 | |
386 # Does this issue have children? | |
387 def children? | |
388 !leaf? | |
359 end | 389 end |
360 | 390 |
361 # Users the issue can be assigned to | 391 # Users the issue can be assigned to |
362 def assignable_users | 392 def assignable_users |
363 project.assignable_users | 393 project.assignable_users |
819 ActiveRecord::Base.connection.select_all("select s.id as status_id, | 849 ActiveRecord::Base.connection.select_all("select s.id as status_id, |
820 s.is_closed as closed, | 850 s.is_closed as closed, |
821 j.id as #{select_field}, | 851 j.id as #{select_field}, |
822 count(i.id) as total | 852 count(i.id) as total |
823 from | 853 from |
824 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{joins} as j | 854 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{joins} j |
825 where | 855 where |
826 i.status_id=s.id | 856 i.status_id=s.id |
827 and #{where} | 857 and #{where} |
828 and i.project_id=#{project.id} | 858 and i.project_id=#{project.id} |
829 group by s.id, s.is_closed, j.id") | 859 group by s.id, s.is_closed, j.id") |