Project

General

Profile

Actions

Defect #6472

closed

"Gantt" doesn't work with oracle database

Added by Nelzin Alexander over 13 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
2010-09-23
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

ArgumentError in Gantts#show 

Showing app/views/gantts/show.html.erb where line #180 raised: 
comparison of Date with Time failed

Extracted source (around line #180): 
177:     i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
178:     i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )
179:     
180:     i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
181:     
182:     i_left = ((i_start_date - @gantt.date_from)*zoom).floor     
183:     i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2                  # total width of the issue (- 2 for left and right borders)

RAILS_ROOT: /Users/alexander_nelzin/Sites/redmine-1.0

To get rid of this error we should convert comparable variables to one type.
I converted Time variables i_start_date and i_end_date to Date in lines 177 and 178

    i_start_date = (i.start_date >= @gantt.date_from ? i.start_date.to_date : @gantt.date_from )
    i_end_date = (i.due_before <= @gantt.date_to ? i.due_before.to_date : @gantt.date_to )

Also after this fix another comparison error appears

TypeError in Gantts#show 

Showing app/views/gantts/show.html.erb where line #184 raised: 
can't convert Date into Float

Extracted source (around line #184): 
181:     
182:     i_left = ((i_start_date - @gantt.date_from)*zoom).floor     
183:     i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2                  # total width of the issue (- 2 for left and right borders)
184:     d_width = ((i_done_date - i_start_date)*zoom).floor - 2                     # done width
185:     l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
186:   css = "task " + (i.leaf? ? 'leaf' : 'parent')
187:     %>

To fix it we should convert i_done_date to Date time again, because in line 176 it becomes float:

    i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor

Here is my patch to make Gantts work:

Index: app/views/gantts/show.html.erb
===================================================================
--- app/views/gantts/show.html.erb    (revision 1537)
+++ app/views/gantts/show.html.erb    (revision 1550)
@@ -170,10 +170,10 @@
 top = headers_height + 10
 @gantt.events.each do |i| 
   if i.is_a? Issue 
-    i_start_date = (i.start_date >= @gantt.date_from ? i.start_date : @gantt.date_from )
-    i_end_date = (i.due_before <= @gantt.date_to ? i.due_before : @gantt.date_to )
-    
-    i_done_date = i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor
+    i_start_date = (i.start_date >= @gantt.date_from ? i.start_date.to_date : @gantt.date_from )
+    i_end_date = (i.due_before <= @gantt.date_to ? i.due_before.to_date : @gantt.date_to )
+
+    i_done_date = (i.start_date + ((i.due_before - i.start_date+1)*i.done_ratio/100).floor).to_date
     i_done_date = (i_done_date <= @gantt.date_from ? @gantt.date_from : i_done_date )
     i_done_date = (i_done_date >= @gantt.date_to ? @gantt.date_to : i_done_date )

Note. The revisions shown here are my local revisions, not yours.


Files

gantt_dates_fix.diff (1016 Bytes) gantt_dates_fix.diff Nelzin Alexander, 2010-09-23 10:43

Related issues

Related to Redmine - Feature #944: Oracle Support in RedmineClosed2008-03-28

Actions
Actions

Also available in: Atom PDF