Commit 49de843d by --eg

refs #2756 done_ratio alanı yerine done_ratio_actual isimli alanı kullanmak için…

… gerekli değişiklikler.
1 parent 05c27bd2
......@@ -7,8 +7,10 @@
<div class="splitcontentright">
<% if @issue.leaf? %>
<p><%= form.select :done_ratio_actual, ((0..100).to_a.collect {|k| ["#{k} %", k] }) %></p>
<p><%= form.select :done_ratio_planned, ((0..100).to_a.collect {|k| ["#{k} %", k] }) %></p>
<% else %>
<p><%= hidden_field_tag :done_ratio_actual, @issue.done_ratio_actual %></p>
<p><%= hidden_field_tag :done_ratio_planned, @issue.done_ratio_planned %></p>
<% end %>
<p><%= hidden_field_tag :done_ratio_over_total_planned, @issue.done_ratio_over_total_planned %></p>
......
<% Rails.logger.debug "issue id #{@issue.id} weight #{@issue.weight}" %>
<tr>
<th class="weight"><%= l(:field_weight) %>:</th>
<td class="weight"><%= progress_bar @issue.weight, :width => '80px', :legend => "#{@issue.weight}%" %></td>
......@@ -7,11 +6,18 @@
:width => '80px', :legend => "%0.1f%" % @issue.done_ratio_over_total %></td>
</tr>
<tr>
<th class="done_ratio_planned"><%= l(:field_done_ratio_planned) %>:</th>
<td class="done_ratio_planned"><%= progress_bar @issue.done_ratio_planned,
:width => '80px', :legend => "%0.1f%" % @issue.done_ratio_planned %></td>
<th class="done_ratio_actual">
<%= l(:field_done_ratio_actual) %>:
</th>
<td class="done_ratio_actual">
<%= progress_bar @issue.done_ratio_actual, :width => '80px', :legend => "%0.1f%" % @issue.done_ratio_actual %>
</td>
<th class="done_ratio_over_total_planned"><%= l(:field_done_ratio_over_total_planned) %>:</th>
<td class="done_ratio_over_total_planned"><%= progress_bar @issue.done_ratio_over_total_planned,
:width => '80px', :legend => "%0.1f%" % @issue.done_ratio_over_total_planned %></td>
</tr>
<tr>
<th class="done_ratio_planned"><%= l(:field_done_ratio_planned) %>:</th>
<td class="done_ratio_planned"><%= progress_bar @issue.done_ratio_planned,
:width => '80px', :legend => "%0.1f%" % @issue.done_ratio_planned %></td>
</tr>
......@@ -4,8 +4,8 @@
<div class="progress box">
<h3><%=l(:label_project_issues_progress_status)%></h3>
<div style="padding 0 20px;">
<%= progress_bar(@project.issues_pourcent_done_ratio, :width => '60%',
:legend => ('%0.0f%s' % [@project.issues_pourcent_done_ratio, l(:field_done_ratio)])) %>
<%= progress_bar(@project.issues_pourcent_done_ratio_actual, :width => '60%',
:legend => ('%0.0f%s' % [@project.issues_pourcent_done_ratio_actual, l(:field_done_ratio_actual)])) %>
<%= progress_bar(@project.issues_pourcent_done_ratio_planned, :width => '60%',
:legend => ("%0.0f%s" % [@project.issues_pourcent_done_ratio_planned, l(:field_done_ratio_planned)])) %>
</div>
......
......@@ -19,6 +19,8 @@
<%= progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '40em', :legend => ('%0.0f%' % version.completed_pourcent)) %>
<%= progress_bar(version.issues_progress_planned, :width => '40em',
:legend => ("%0.0f%s" % [version.issues_progress_planned, l(:field_done_ratio_planned)])) %>
<%= progress_bar(version.issues_progress_actual, :width => '40em',
:legend => ("%0.0f%s" % [version.issues_progress_planned, l(:field_done_ratio_planned)])) %>
<p class="progress-info">
<%= link_to(l(:label_x_issues, :count => version.issues_count),
project_issues_path(version.project, :status_id => '*', :fixed_version_id => version, :set_filter => 1)) %>
......
# English strings go here for Rails i18n
en:
field_weight: "% Weight"
field_done_ratio_actual: "% Done completed"
field_done_ratio_planned: "% Done planned"
field_done_ratio_over_total: "% Done over total done"
field_done_ratio_over_total_planned: "% Done over total done planned"
......
# Turkish strings go here for Rails i18n
en:
field_weight: "% Ağırlık"
field_done_ratio_actual: "% Gerçekleşen tamamlanma"
field_done_ratio_planned: "% Planlanan tamamlanma"
field_done_ratio_over_total: "% Toplam tamamlanmaya etki"
field_done_ratio_over_total_planned: "% Planlanan toplam tamamlanmaya etki"
......
class CreateIssuesWeightColumns < ActiveRecord::Migration
def self.up
add_column :issues, :weight, :integer, :null => false, :default => 100
add_column :issues, :done_ratio_actual, :float, :null => false, :default => 100.0
add_column :issues, :done_ratio_actual, :float, :null => false, :default => 0.0
add_column :issues, :done_ratio_planned, :float, :null => false, :default => 100.0
add_column :issues, :done_ratio_over_total, :float, :null => false, :default => 0.0
add_column :issues, :done_ratio_over_total_planned, :float, :null => false, :default => 0.0
......
......@@ -24,6 +24,9 @@ module RedmineIssueWeight
unless params[:issue][:done_ratio_planned].blank?
context[:issue].done_ratio_planned = params[:issue][:done_ratio_planned]
end
unless params[:issue][:done_ratio_actual].blank?
context[:issue].done_ratio_actual = params[:issue][:done_ratio_actual]
end
end
child_issue = context[:issue]
......@@ -36,7 +39,7 @@ module RedmineIssueWeight
parent_percent *= 100
end
context[:issue].done_ratio_over_total = context[:issue].done_ratio * parent_weight / parent_percent
context[:issue].done_ratio_over_total = context[:issue].done_ratio_actual * parent_weight / parent_percent
context[:issue].done_ratio_over_total_planned = context[:issue].done_ratio_planned * parent_weight / parent_percent
end
end
......
......@@ -18,36 +18,41 @@ module RedmineIssueWeight
rval = recalculate_attributes_for_without_weight(issue_id)
if issue_id && p = Issue.find_by_id(issue_id)
# done ratio = weighted average ratio of leaves
unless Issue.use_status_for_done_ratio? && p.status && p.status.default_done_ratio
children_count = p.children.count
if children_count > 0
done = p.children.sum("(CASE WHEN is_closed = #{connection.quoted_true} THEN 100 ELSE COALESCE(done_ratio, 0) END) * COALESCE(weight, 100)", :joins => :status).to_f
done_planned = p.children.sum("COALESCE(done_ratio_planned, 0) * COALESCE(weight, 100)", :joins => :status).to_f
# progress = done / (average * leaves_count * 100)
# progress = done / (children_count * 100)
progress = done / 100
p.done_ratio = progress.round
# p.done_ratio_planned = done_planned / (children_count * 100)
p.done_ratio_planned = done_planned / 100
end
child_issue = p
parent_weight = p.weight
parent_percent = 100.0
while !child_issue.parent.blank?
child_issue = child_issue.parent
parent_weight *= child_issue.weight
parent_percent *= 100
end
p.done_ratio_over_total = p.done_ratio * parent_weight / parent_percent
p.done_ratio_over_total_planned = p.done_ratio_planned * parent_weight / parent_percent
# actual done ratio = weighted average ratio of leaves
children_count = p.children.count
if children_count > 0
da_cond =
"COALESCE(done_ratio_actual, 0) * COALESCE(weight, 100)"
done_actual = p.children.sum(da_cond, :joins => :status).to_f
dp_cond =
"COALESCE(done_ratio_planned, 0) * COALESCE(weight, 100)"
done_planned = p.children.sum(dp_cond, :joins => :status).to_f
# progress = done / (average * leaves_count * 100)
# progress = done / (children_count * 100)
progress = done_actual / 100
p.done_ratio_actual = progress.round
# p.done_ratio_planned = done_planned / (children_count * 100)
p.done_ratio_planned = done_planned / 100
end
child_issue = p
parent_weight = p.weight
parent_percent = 100.0
while !child_issue.parent.blank?
child_issue = child_issue.parent
parent_weight *= child_issue.weight
parent_percent *= 100
end
p.done_ratio_over_total =
p.done_ratio_actual * parent_weight / parent_percent
p.done_ratio_over_total_planned =
p.done_ratio_planned * parent_weight / parent_percent
# ancestors will be recursively updated
p.save(false)
end
......
......@@ -15,12 +15,14 @@ module RedmineIssueWeight
module InstanceMethods
def issues_pourcent_done_ratio_planned
total_progress = self.issues.hasnoparent.sum("weight * done_ratio_planned").to_f
total_progress =
self.issues.hasnoparent.sum("weight * done_ratio_planned").to_f
total_progress / 100
end
def issues_pourcent_done_ratio
total_progress = self.issues.hasnoparent.sum("weight * done_ratio").to_f
def issues_pourcent_done_ratio_actual
total_progress =
self.issues.hasnoparent.sum("weight * done_ratio_actual").to_f
total_progress / 100
end
......
......@@ -17,10 +17,17 @@ module RedmineIssueWeight
def column_value_with_weight(column, issue, value)
rval = column_value_without_weight(column, issue, value)
weight_column_names = [:weight, :done_ratio_planned, :done_ratio_over_total, :done_ratio_over_total_planned]
if ['Fixnum', 'Float'].include? value.class.name and weight_column_names.include? column.name
progress_bar(value, :width => '80px')
weight_column_names = [
:weight,
:done_ratio_actual,
:done_ratio_planned,
:done_ratio_over_total,
:done_ratio_over_total_planned
]
is_numeric_value = ['Fixnum', 'Float'].include?( value.class.name )
if is_numeric_value && weight_column_names.include?( column.name )
progress_bar( value, :width => '80px' )
else
rval
end
......
......@@ -11,6 +11,7 @@ module RedmineIssueWeight
unloadable # to make sure plugin is loaded in development mode
base.add_available_column(QueryColumn.new(:weight, :sortable => "#{Issue.table_name}.weight", :groupable => true))
base.add_available_column(QueryColumn.new(:done_ratio_actual, :sortable => "#{Issue.table_name}.done_ratio_actual", :groupable => true))
base.add_available_column(QueryColumn.new(:done_ratio_planned, :sortable => "#{Issue.table_name}.done_ratio_planned", :groupable => true))
base.add_available_column(QueryColumn.new(:done_ratio_over_total, :sortable => "#{Issue.table_name}.done_ratio_over_total", :groupable => true))
base.add_available_column(QueryColumn.new(:done_ratio_over_total_planned, :sortable => "#{Issue.table_name}.done_ratio_over_total_planned", :groupable => true))
......@@ -22,14 +23,21 @@ module RedmineIssueWeight
module InstanceMethods
def available_filters_with_weight
@available_filters = available_filters_without_weight
# find max order
max_order = @available_filters.map { |k, v| v[:order] }.max
weight_filters = {
"weight" => { :type => :integer, :order => 40 },
"done_ratio_planned" => { :type => :float, :order => 41},
"done_ratio_over_total" => { :type => :float, :order => 42},
"done_ratio_over_total_planned" => { :type => :float, :order => 43}
"weight" => {:type => :integer, :order => max_order + 1},
"done_ratio_actual" => {:type => :float, :order => max_order + 2},
"done_ratio_planned" => {:type => :float, :order => max_order + 3},
"done_ratio_over_total" =>
{:type => :float, :order => max_order + 4},
"done_ratio_over_total_planned" =>
{:type => :float, :order => max_order + 5}
}
@available_filters = available_filters_without_weight
@available_filters.merge(weight_filters)
end
......
......@@ -9,7 +9,6 @@ module RedmineIssueWeight
base.class_eval do
unloadable # to make sure plugin is loaded in development mode
alias_method_chain :issues_progress, :weight
end
end
......@@ -29,24 +28,19 @@ module RedmineIssueWeight
progress
end
def issues_progress_with_weight(open)
@issues_progress ||= {}
@issues_progress[open] ||= begin
progress = 0
if issues_count > 0
ratio = open ? 'done_ratio' : 100
def issues_progress_actual
progress = 0
unless (fixed_issues.hasnoparent.count == 0)
done = fixed_issues.hasnoparent.sum("weight * #{ratio}", :joins => :status,
:conditions => ["#{IssueStatus.table_name}.is_closed = ?", !open]).to_f
if issues_count > 0
unless (fixed_issues.hasnoparent.count == 0)
done = fixed_issues.hasnoparent.sum("weight * done_ratio_actual" ).to_f
progress = done / (estimated_average * 100)
end
progress = done / 100
end
progress
end
end
progress
end
end
end
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!