Skip to content

Commit

Permalink
Adding more columns:
Browse files Browse the repository at this point in the history
- Calculated spent time = Estimated time * % Done
- Divergent time = Spent time - Calculated spent time
- Remaining time = Estimated time - (Estimated time * % Done)
  • Loading branch information
Jan Schulz-Hofen committed Jul 7, 2011
1 parent 8081977 commit 41dfdb4
Show file tree
Hide file tree
Showing 48 changed files with 219 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config/locales/bg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'bg':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/bs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'bs':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/ca.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'ca':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'cs':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/da.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'da':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'de':
label_calculated_spent_hours: Rechnerisch aufgewendete Zeit
label_divergent_hours: Zeitabweichung
label_remaining_hours: Verbleibende Zeit
4 changes: 4 additions & 0 deletions config/locales/el.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'el':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/en-GB.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'en-GB':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
en:
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'es':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/eu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'eu':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/fa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'fa':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/fi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'fi':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'fr':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/gl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'gl':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/he.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'he':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/hr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'hr':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/hu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'hu':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'id':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'it':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'ja':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/ko.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'ko':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/lt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'lt':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/lv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'lv':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/mk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'mk':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/mn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'mn':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'nl':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/no.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'no':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/pl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'pl':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'pt-BR':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/pt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'pt':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/ro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'ro':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'ru':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/sk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'sk':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/sl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'sl':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/sr-YU.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'sr-YU':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/sr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'sr':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/sv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'sv':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/th.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'th':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'tr':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/uk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'uk':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/vi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'vi':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/zh-TW.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'zh-TW':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
4 changes: 4 additions & 0 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'zh':
label_calculated_spent_hours: Calculated spent time
label_divergent_hours: Divergent time
label_remaining_hours: Remaining time
3 changes: 2 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'dispatcher'

Dispatcher.to_prepare do
Issue.send(:include, RedmineSpentTimeColumn::Patches::IssuePatch) unless Issue.include?(RedmineSpentTimeColumn::Patches::IssuePatch)
Query.send(:include, RedmineSpentTimeColumn::Patches::QueryPatch) unless Query.include?(RedmineSpentTimeColumn::Patches::QueryPatch)
QueriesHelper.send(:include, RedmineSpentTimeColumn::Patches::QueriesHelperPatch) unless QueriesHelper.include?(RedmineSpentTimeColumn::Patches::QueriesHelperPatch)
end
Expand All @@ -10,5 +11,5 @@
name 'Redmine Spent Time Column'
author 'Jan Schulz-Hofen, Planio GmbH'
description 'This plugin adds a spent time column to issue lists.'
version '1.0.0'
version '1.1.0'
end
19 changes: 19 additions & 0 deletions lib/redmine_spent_time_column/patches/issue_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module RedmineSpentTimeColumn
module Patches
module IssuePatch

def calculated_spent_hours
@calculated_spent_hours ||= self_and_descendants.sum("estimated_hours * done_ratio / 100").to_f || 0.0
end

def divergent_hours
@divergent_hours ||= spent_hours - calculated_spent_hours
end

def remaining_hours
@remaining_hours ||= self_and_descendants.sum("estimated_hours - (estimated_hours * done_ratio / 100)").to_f || 0.0
end

end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module QueriesHelperPatch

def column_content_with_spent_hours(column, issue)
value = column.value(issue)
if %w(Fixnum Float).include?( value.class.name ) and column.name == :spent_hours
if %w(Fixnum Float).include?( value.class.name ) and [:spent_hours, :calculated_spent_hours, :divergent_hours, :remaining_hours].include?(column.name)
sprintf "%.2f", value
else
column_content_without_spent_hours(column, issue)
Expand Down
22 changes: 21 additions & 1 deletion lib/redmine_spent_time_column/patches/query_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,27 @@ module QueryPatch
def available_columns_with_spent_hours
returning available_columns_without_spent_hours do |columns|
if (project and User.current.allowed_to?(:view_time_entries, project)) or User.current.admin?
columns << QueryColumn.new(:spent_hours, :caption => :label_spent_time, :sortable => "(select sum(hours) from #{TimeEntry.table_name} where #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id)") unless columns.detect{ |c| c.name == :spent_hours }

columns << QueryColumn.new(:spent_hours,
:caption => :label_spent_time,
:sortable => "(select sum(hours) from #{TimeEntry.table_name} where #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id)"
) unless columns.detect{ |c| c.name == :spent_hours }

columns << QueryColumn.new(:calculated_spent_hours,
:caption => :label_calculated_spent_hours,
:sortable => "(IF(#{Issue.table_name}.estimated_hours IS NULL,0,#{Issue.table_name}.estimated_hours) * #{Issue.table_name}.done_ratio / 100)"
) unless columns.detect{ |c| c.name == :calculated_spent_hours }

columns << QueryColumn.new(:divergent_hours,
:caption => :label_divergent_hours,
:sortable => "((select sum(hours) from #{TimeEntry.table_name} where #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id) - (IF(#{Issue.table_name}.estimated_hours IS NULL,0,#{Issue.table_name}.estimated_hours) * #{Issue.table_name}.done_ratio / 100))"
) unless columns.detect{ |c| c.name == :divergent_hours }

columns << QueryColumn.new(:remaining_hours,
:caption => :label_remaining_hours,
:sortable => "(IF(#{Issue.table_name}.estimated_hours IS NULL,0,#{Issue.table_name}.estimated_hours) - (IF(#{Issue.table_name}.estimated_hours IS NULL,0,#{Issue.table_name}.estimated_hours) * #{Issue.table_name}.done_ratio / 100))"
) unless columns.detect{ |c| c.name == :remaining_hours }

end
end
end
Expand Down

0 comments on commit 41dfdb4

Please sign in to comment.