pharmazone / redmine_charts2

Plugin which integrates with Redmine 2.0.3 and 2.1.x following charts: burndown, timeline, ratios of logged hours and issues, deviations of logged hours.

Home Page:http://github.com/pharmazone/redmine_charts2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Burndown, Logged Hours Timeline throw 500 Error

markpennington opened this issue · comments

This plugin looks promising, thank you for the work. Both the Burndown and Timeline charts throw a 500 error both of which are related to an invalid date argument. No other charts have this error. i also installed this on a blank Bitnami Redmine setup with no errors. But this instance has 6 years of data and now am seeing this. Thanks again.

Redmine setup:
Environment:
Redmine version 2.1.5.stable
Ruby version 1.9.3 (x86_64-linux)
Rails version 3.2.8
Environment development
Database adapter Mysql2
Redmine plugins:
redmine_charts2 0.2.1

Burndown Error Log:
ChartSavedCondition Load (0.7ms) SELECT chart_saved_conditions.* FROM chart_saved_conditions WHERE (project_id is null or project_id = 14)
Issue Load (71.4ms) SELECT issues.* FROM issues WHERE issues.project_id IN (14)
ChartTimeEntry Load (1.1ms) SELECT month, week, day FROM chart_time_entries left join issues on issues.id = issue_id WHERE (day > 0 AND chart_time_entries.project_id in (14)) ORDER BY 1 asc, 2 asc, 3 asc LIMIT 1
Completed 500 Internal Server Error in 574ms

ArgumentError (invalid date):
plugins/redmine_charts2/lib/redmine_charts/range_utils.rb:182:in strptime' plugins/redmine_charts2/lib/redmine_charts/range_utils.rb:182:insubtract_week'
plugins/redmine_charts2/lib/redmine_charts/range_utils.rb:76:in prepare_range' plugins/redmine_charts2/app/models/chart_time_entry.rb:27:inget_timeline'
plugins/redmine_charts2/app/controllers/charts_burndown_controller.rb:55:in get_data_for_burndown_chart' plugins/redmine_charts2/app/controllers/charts_burndown_controller.rb:8:inget_data'
plugins/redmine_charts2/app/controllers/charts_controller.rb:111:in create_chart' plugins/redmine_charts2/app/controllers/charts_controller.rb:84:inindex'

Timeline Error Log:
ChartSavedCondition Load (0.7ms) SELECT chart_saved_conditions.* FROM chart_saved_conditions WHERE (project_id is null or project_id = 14)
ChartTimeEntry Load (0.8ms) SELECT month, week, day FROM chart_time_entries left join issues on issues.id = issue_id WHERE (day > 0 AND chart_time_entries.project_id in (14)) ORDER BY 1 asc, 2 asc, 3 asc LIMIT 1
Completed 500 Internal Server Error in 99ms

ArgumentError (invalid date):
plugins/redmine_charts2/lib/redmine_charts/range_utils.rb:182:in strptime' plugins/redmine_charts2/lib/redmine_charts/range_utils.rb:182:insubtract_week'
plugins/redmine_charts2/lib/redmine_charts/range_utils.rb:76:in prepare_range' plugins/redmine_charts2/app/models/chart_time_entry.rb:27:inget_timeline'
plugins/redmine_charts2/app/controllers/charts_timeline_controller.rb:8:in get_data' plugins/redmine_charts2/app/controllers/charts_controller.rb:111:increate_chart'
plugins/redmine_charts2/app/controllers/charts_controller.rb:84:in `index'

I'm working on this funny bug right now.

I've catch this bug tomorrow morning and problem is in the ruby Date.strptime function.

It works incorrect with "week 0" - week before first Sunday or Monday in the year:

Date.strptime('2013-1', "%Y-%W")
=> Mon, 07 Jan 2013

Date.strptime('2013-0', "%Y-%W")
ArgumentError: invalid date

I will fix the bug in hour.

I finally fixed this bug in both branch.