256MbTeam / Redmine-Scrumbler

Easy to use plugin for Redmine. It allows users to use the Scrum/Agile process in projects. Scrumbler have interactive dashboard with the ability to configure for each sprint. Plugin adds Scrum Points field in every issue in project. Scrumbler as possible using the standard redmine structure of projects.
GNU General Public License v2.0
112 stars 41 forks source link

Burndown graph internal error with closed issue #82

Open cassianomonteiro opened 12 years ago

cassianomonteiro commented 12 years ago

The burndown graph is working fine with all issues opened. But as soon as I closed one issue, I got Internal Error 500. My log shows this:

Processing ScrumblerSprintsController#burndown (for 10.3.14.33 at 2012-07-04 14:32:26) [GET]
  Parameters: {"project_id"=>"epb-ipad", "action"=>"burndown", "id"=>"2", "controller"=>"scrumbler_sprints"}

ArgumentError (odd number of arguments for Hash):
  vendor/plugins/redmine_scrumbler/app/controllers/scrumbler_sprints_controller.rb:174:in `[]'
  vendor/plugins/redmine_scrumbler/app/controllers/scrumbler_sprints_controller.rb:174:in `burndown_calc'
  vendor/plugins/redmine_scrumbler/app/controllers/scrumbler_sprints_controller.rb:121:in `burndown'
  config/initializers/mongrel.rb:62:in `dispatch_cgi'

Rendering C:/webserver/Redmine/public/500.html (500 Internal Server Error)

I´m using Redmine 1.4.4, with Scrumbler commit 1d8002f2bbb7168c166000ba364045c2de4851ee (redmine 1.4.x support from may 2nd). Ruby version: 1.8.7 Rails version: 2.3.14

Gem list:

*** LOCAL GEMS ***

actionmailer (2.3.14)
actionpack (2.3.14)
activerecord (2.3.14)
activeresource (2.3.14)
activesupport (2.3.14)
bundler (1.1.3)
cgi_multipart_eof_fix (2.5.0)
coderay (1.0.6)
fastercsv (1.5.5, 1.5.4)
gem_plugin (0.2.3)
i18n (0.4.2)
json (1.6.6, 1.6.3)
mongrel (1.1.5 x86-mingw32)
mongrel_service (0.3.4 i386-mswin32)
mysql (2.8.1 x86-mingw32)
net-ldap (0.3.1)
pg (0.13.2 x86-mingw32)
rack (1.1.3, 1.1.1)
rails (2.3.14)
rake (0.9.2.2, 0.8.7)
rdoc (3.12)
rmagick (2.13.1)
ruby-openid (2.1.8)
sqlite3 (1.3.6 x86-mingw32, 1.3.5 x86-mingw32)
tzinfo (0.3.33)
win32-service (0.5.2 mswin32)
cassianomonteiro commented 12 years ago

Turns out it was because of the ruby version 1.8.7. The Hash#[] method from 1.9.3 is able to take a 2-dimention array, but the one from 1.8.7 can´t do it.

I worked around that that by manually adding the items to the hash, as the code below (method burndown_calc, line 174). Sorry, but i´m not skilled with ruby, probably there is a much clever way to do it.

#    closed_issues = Hash[closed_issues.group_by(&:due_date).map {|k,v|
#      [k, v.inject(0.0) {|t,is|
#          t+= is.custom_value_for(ScrumblerIssueCustomField.points).try(:value).to_f }
#      ]}]

    closed_issues_array = closed_issues.group_by(&:due_date).map {|k,v|
      [k, v.inject(0.0) {|t,is|
          t+= is.custom_value_for(ScrumblerIssueCustomField.points).try(:value).to_f }
      ]}
    closed_issues = Hash.new
    closed_issues_array.each { |x| closed_issues[x[0]] = x[1] }