Permalink
Browse files

Fixed milestone issue belonging logic

  • Loading branch information...
1 parent 2d3abee commit abb3fc6ac118996386628f2b162e6e4455dc4d52 @k41n committed Oct 18, 2012
View
15 app/models/milestone.rb
@@ -77,6 +77,12 @@ def ansectors(visited = [])
visited.flatten.uniq
end
+ def descendants(visited = [])
+ visited << self.id
+ visited << self.children.reject{|x| visited.include? x.id}.collect{|x| x.descendants} unless self.children.empty?
+ visited.flatten.uniq
+ end
+
def assigned_projects=(projects)
self.projects = projects.collect{|x| Project.find(x)}
end
@@ -123,7 +129,8 @@ def closed_pourcent
end
def issues_count
- all_issues.count
+ load_issue_counts
+ @issue_count
end
def start_date
@@ -264,12 +271,6 @@ def <=> (a)
self.name <=> a.name
end
- #def level
- # return 0 if self.parent_milestone.nil? and self.kind == "aggregate"
- # return 1 if self.parent_milestone.nil? and self.kind == "internal"
- # return parent_milestone.level + 1
- #end
-
def versionless?
self.version.nil?
end
View
5 app/views/milestones/_milestone.html.erb
@@ -19,10 +19,11 @@
<% if milestone.issues_count > 0 %>
<%= progress_bar([milestone.closed_pourcent, milestone.completed_pourcent], :width => '35em', :legend => '%0.0f%' % milestone.completed_pourcent) %>
<p class="progress-info">
- <%= link_to_if(milestone.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => milestone.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => milestone.project, :status_id => 'c', :milestone_id => milestone.id, :set_filter => 1) %>
+ <%= link_to_if(milestone.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => milestone.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => milestone.project, :status_id => 'c', :milestone => milestone, :set_filter => 1) %>
(<%= '%0.0f' % (milestone.closed_issues_count.to_f / milestone.issues_count * 100) %>%)
&#160;
- <%= link_to_if(milestone.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => milestone.open_issues_count), :controller => 'issues', :action => 'index', :project_id => milestone.project, :status_id => 'o', :milestone_id => milestone.id, :set_filter => 1) %>
+ <%= link_to_if(milestone.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => milestone.open_issues_count), :controller => 'issues', :action => 'index', :project_id => milestone.project, :status_id => 'o', :milestone => milestone, :set_filter => 1) %>
+ <% logger.info "====================== #{milestone.open_issues_count.to_f} / #{milestone.issues_count} ==============" %>
(<%= '%0.0f' % (milestone.open_issues_count.to_f / milestone.issues_count * 100) %>%)
</p>
<% else %>
View
8 app/views/milestones/show.html.erb
@@ -31,11 +31,11 @@
<% if @milestone.issues_count > 0 %>
<%= progress_bar([@milestone.closed_pourcent, @milestone.completed_pourcent], :width => '35em', :legend => '%0.0f%' % @milestone.completed_pourcent) %>
<p class="progress-info">
- <%= link_to_if(@milestone.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => @milestone.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => @milestone.project, :status_id => 'c', :milestone_id => @milestone.id, :set_filter => 1) %>
- (<%= '%0.0f' % (@milestone.closed_issues_count.to_f / @milestone.issues.count * 100) %>%)
+ <%= link_to_if(@milestone.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => @milestone.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => @milestone.project, :status_id => 'c', :milestone => @milestone, :set_filter => 1) %>
+ (<%= '%0.0f' % (@milestone.closed_issues_count.to_f / @milestone.issues_count * 100) %>%)
&#160;
- <%= link_to_if(@milestone.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => @milestone.open_issues_count), :controller => 'issues', :action => 'index', :project_id => @milestone.project, :status_id => 'o', :milestone_id => @milestone.id, :set_filter => 1) %>
- (<%= '%0.0f' % (@milestone.open_issues_count.to_f / @milestone.issues.count * 100) %>%)
+ <%= link_to_if(@milestone.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => @milestone.open_issues_count), :controller => 'issues', :action => 'index', :project_id => @milestone.project, :status_id => 'o', :milestone => @milestone, :set_filter => 1) %>
+ (<%= '%0.0f' % (@milestone.open_issues_count.to_f / @milestone.issues_count * 100) %>%)
</p>
<% else %>
<p class="progress-info"><%= l(:label_roadmap_no_issues_for_milestone) %></p>
View
7 lib/milestones/query_patch.rb
@@ -8,9 +8,6 @@ def self.included(base)
base.class_eval do
unloadable
- # alias_method :statement_original_contacts, :statement
- # alias_method :statement, :statement_contacts
-
alias_method :available_filters_original_milestone, :available_filters
alias_method :available_filters, :available_filters_milestone
@@ -23,7 +20,9 @@ def self.included(base)
module InstanceMethods
def sql_for_milestone_field(field, operator, value)
compare = operator == '=' ? 'IN' : 'NOT IN'
- milestones_select = "#{value.join(',')}"
+ milestones = Milestone.find(:all, :conditions => {:id => value})
+ values = milestones.map(&:descendants).flatten.uniq
+ milestones_select = "#{values.join(',')}"
"(#{Issue.table_name}.milestone_id #{compare} (#{milestones_select}))"
end

0 comments on commit abb3fc6

Please sign in to comment.