Created
August 1, 2013 21:35
-
-
Save tomasv/6135566 to your computer and use it in GitHub Desktop.
Add a very custom velocity counter to sprints in redmine backlogs plugin master backlog page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/models/rb_sprint.rb b/app/models/rb_sprint.rb | |
index 3bed08b..4ba4961 100644 | |
--- a/app/models/rb_sprint.rb | |
+++ b/app/models/rb_sprint.rb | |
@@ -69,6 +69,24 @@ class RbSprint < Version | |
return stories.inject(0){|sum, story| sum + story.story_points.to_i} | |
end | |
+ def velocity | |
+ return unless project.present? | |
+ | |
+ spent_time = stories.inject(0) { |sum, story| | |
+ story.time_entries.map(&:hours).sum + sum | |
+ } | |
+ done_points = stories.select(&:closed?). | |
+ inject(0) { |sum, story| story.story_points + sum } | |
+ | |
+ ratio = if spent_time.zero? | |
+ 0 | |
+ else | |
+ done_points / spent_time | |
+ end | |
+ | |
+ "Spent: #{spent_time}, done: #{done_points}, velocity: #{ratio}" | |
+ end | |
+ | |
def has_wiki_page | |
return false if wiki_page_title.blank? | |
diff --git a/app/views/rb_sprints/_sprint.html.erb b/app/views/rb_sprints/_sprint.html.erb | |
index 8cdcba7..708095b 100644 | |
--- a/app/views/rb_sprints/_sprint.html.erb | |
+++ b/app/views/rb_sprints/_sprint.html.erb | |
@@ -7,6 +7,7 @@ | |
<div class="fff-wrapmiddle"> | |
<div class="fff-middle"> | |
<div class="name editable" fieldname="name" fieldlabel="<%=l(:field_name)%>"><%= h sprint.name %></div> | |
+ <div class="custom-velocity" fieldname="velocity" fieldlabel="<%=l(:field_name)%>"><%= sprint.velocity %></div> | |
</div> | |
</div> | |
diff --git a/assets/stylesheets/master_backlog.css b/assets/stylesheets/master_backlog.css | |
index 4131caf..57419ba 100644 | |
--- a/assets/stylesheets/master_backlog.css | |
+++ b/assets/stylesheets/master_backlog.css | |
@@ -2,7 +2,7 @@ | |
* reserved classes are | |
* .backlog (used in master_backlog.js to initialize all backlogs) | |
* .model (used in backlog.js editable_inplace.js model.js) | |
- * .sprint (used in backlog.js | |
+ * .sprint (used in backlog.js | |
* .stories (used in backlog.js for sortable) | |
* .editor | |
* .editable (bind click on) | |
@@ -286,7 +286,7 @@ ul li { vertical-align: bottom; } /* close IE7 gap between list items */ | |
.header .date{ | |
height:28px; | |
line-height:28px; | |
- white-space: nowrap; | |
+ white-space: nowrap; | |
font-size:12px; | |
} | |
@@ -710,3 +710,11 @@ ul li { vertical-align: bottom; } /* close IE7 gap between list items */ | |
/* show completed sprints */ | |
#show_completed_sprints { cursor:pointer; } | |
+ | |
+.fff-middle div { | |
+ display: inline-block; | |
+} | |
+ | |
+.custom-velocity { | |
+ margin-left: 20px; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment