Defect #7335
Sorting issues in new gantt (v1.1.0)
| Status: | New | Start date: | 2011-01-15 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 100% | |
| Category: | Gantt | |||
| Target version: | 2.4.0 | |||
| Affected version: | 1.1.0 | Resolution: |
Description
I can't tell if the prior issues (see below) related to gantt chart issue sorting are about new- or old-style gantt charts. I do know that the default 1.1.0 isn't very useful, since they're sorted by root_id (ie. parent issue id). That has little relation to the order that the issues need to be worked on in. I made a one-line change that worked for me:
- TODO: top level issues should be sorted by start date
def gantt_issue_compare(x, y, issues)
[(x.root.start_date or x.start_date or Date.new()), (x.start_date or Date.new()), x.root_id, x.lft] <=> [(y.root.start_date or y.start_date or Date.new()), (y.start_date or Date.new()), y.root_id, y.lft]
#if x.root_id == y.root_id # x.lft <=> y.lft
#else # #x.root_id <=> y.root_id
#end
end
I'm not 100% certain if it works in all cases, but for my DB (multi-project, multi-version, single nesting level issues), it works fine.
Related issues
Associated revisions
gantt: change sort method to class method (#7335)
gantt: add test to sort issues by current logic (#7335)
gantt: sort issues by start date (#7335)
gantt: sort versions by start date (#7335)
History
#1 Updated by Eli Stevens over 2 years ago
#2 Updated by Guillaume Pellegrin over 2 years ago
Hi Eli,
And thanks for your patch. Worked fine for me. I'll post here in case this breaks some use cases.
Hope this change will be made available in the next release.
Regards,
Guillaume
#3 Updated by Eli Stevens over 2 years ago
Update: the first line didn't work in all cases for me. This one seems to be behaving better:
[(x.root.start_date or x.start_date or Date.new()), x.root_id, (x.start_date or Date.new()), x.lft] <=> [(y.root.start_date or y.start_date or Date.new()), y.root_id, (y.start_date or Date.new()), y.lft]#4 Updated by Sebastian Buckpesch over 2 years ago
Hi,
where do I enter this line of code or apply this patch?
Thanks,
Sebastian
#5 Updated by Etienne Massip over 2 years ago
lib/redmine/helpers/gantt_helper.rb (gantt_issue_compare()) ?
#6 Updated by Sebastian Buckpesch over 2 years ago
thanks. Works fine.
#7 Updated by E M over 2 years ago
Anyone knows if we can also sort by name? Or if the above patch could be easily modified to sort by top level issue name (instead of id like current or start date like this fix)?
feel free to move this to a new issue if you feel it's necessary.
#8 Updated by Fernando Hartmann over 2 years ago
+1
#9 Updated by Carlos Serrano over 2 years ago
thanks. Works fine.
#10 Updated by Cassiano Monteiro about 2 years ago
+1
#11 Updated by Lukas Elmer almost 2 years ago
+1, related with #8480
#12 Updated by Felipe Ribeiro over 1 year ago
- File sort_issues_from_start_date.diff
added - File sort_issues.rb
added
I solved this by changing the way to insert issues in the Data Base. I just insert them already in the correct order.
But also I had to change the values of rgt and lft directly on the Data Base, because there were projects already inserted in the system, and doing this I guarantee that all projects will be sorted correctly.
Is attached the diff file and the new script i had to create.
#13 Updated by Svein-Tore Griff With about 1 year ago
+1
#14 Updated by lmerl andeson about 1 year ago
- Assignee set to Mischa The Evil
#15 Updated by Toshi MARUYAMA 7 months ago
- Assignee deleted (
Mischa The Evil)
#16 Updated by Toshi MARUYAMA 7 months ago
- File redmine-trunk-r10713.png added
- File redmine-trunk-r10713-patch.png added
- File gantt-sort-r10713.diff
added
This is a patch for trunk r10713.
This patch sort start date algorism is referred from Redmine Better Gantt Chart Plugin
But, issues tree structure is broken by start date sorting.
Redmine trunk r10713
¶
Patch applied
¶
#17 Updated by Etienne Massip 7 months ago
FTR the patch in #7456 originally implemented some sorting too.
#18 Updated by Jonathan Vargas 5 months ago
Hi guys.
I just required the sort by start date and then applied manually the first chunk mentioned on sort_issues_from_start_date.diff, to my 2.2.0 version, and it worked as expected.
So, could it be possible to apply it on 2.2's trunk or next versions? I see that a default sorting by start_date first has more sense than by issue_id.
Thanks in advance.
#19 Updated by Toshi MARUYAMA 5 months ago
New patch is posted at #8366.
#20 Updated by Toshi MARUYAMA about 1 month ago
- File gantt-sort-trunk-r11692.diff
added - File gantt-sort-trunk-r11692.png added
I confirmed #8366 Change-Gantt-default-sorting-to-start_date-instead-of-id.patch fixes note-16 problem.
I re-post it as gantt-sort-trunk-r11692.diff .

#21 Updated by Yuhki ISHIGURO about 1 month ago
Thank you for your patch, Toshi.
I applied your patch, and it looked working correctly, first.
However, note-16 problem is still happen to issues which added
after your patch applied.
#22 Updated by Toshi MARUYAMA about 1 month ago
- File gantt-sort-trunk-r11723.diff
added
Yuhki Ishiguro wrote:
Thank you for your patch, Toshi.
I applied your patch, and it looked working correctly, first.
However, note-16 problem is still happen to issues which added
after your patch applied.
Thank you for your trying.
Could you try this patch using another logic.
This logic is from here (in Japanese).
http://d.hatena.ne.jp/itto100pen/20121202
#23 Updated by Yuhki ISHIGURO about 1 month ago
- File gantt.jpg added
Umm... I tried new patch. And, same things happen.
I show you my Test project.
426 wasn't added correctly, but after adding 428, it was solved.

#24 Updated by Toshi MARUYAMA about 1 month ago
- File gantt-sort-trunk-r11740.diff
added
I got a suggestion from patch author.
https://twitter.com/nobu_toyofuku/status/326227862808064000
Could you try this patch?
#25 Updated by Yuhki ISHIGURO about 1 month ago
I tried gantt-sort-trunk-r11740.diff, and it seems working correctly!
Thank you !!
Regards,
Yuhki ISHIGURO
#26 Updated by Toshi MARUYAMA about 1 month ago
- File gantt-sort-trunk-r11744.diff
added
gantt-sort-trunk-r11740.diff does not sort root issues.
This patch fixes it.
#27 Updated by Yuhki ISHIGURO about 1 month ago
Toshi MARUYAMA wrote:
gantt-sort-trunk-r11740.diff does not sort root issues.
This patch fixes it.
I greatly appreciate for you contribution.
I tried your new patch gantt-sort-trunk-r11744.
It works fine, and I think it solves this issue.
Regards,
Yuhki ISHIGURO
#28 Updated by David Dupont 24 days ago
Hi,
I tried to apply patch but errors occured :
root@linus:/var/www/redmine# patch -p0 < gantt-sort-trunk-r11744.diff patching file b/lib/redmine/helpers/gantt.rb Hunk #1 FAILED at 675. 1 out of 1 hunk FAILED -- saving rejects to file b/lib/redmine/helpers/gantt.rb.rej patching file b/lib/redmine/helpers/gantt.rb Hunk #1 FAILED at 687. 1 out of 1 hunk FAILED -- saving rejects to file b/lib/redmine/helpers/gantt.rb.rej patching file b/lib/redmine/helpers/gantt.rb Hunk #1 FAILED at 686. 1 out of 1 hunk FAILED -- saving rejects to file b/lib/redmine/helpers/gantt.rb.rej patching file b/lib/redmine/helpers/gantt.rb Hunk #1 FAILED at 220. Hunk #2 FAILED at 694. 2 out of 2 hunks FAILED -- saving rejects to file b/lib/redmine/helpers/gantt.rb.rej
Some help please ?
Thanks.
Version Info :
Environment:
Redmine version 2.3.0.devel.11744
Ruby version 1.8.7 (x86_64-linux)
Rails version 3.2.13
Environment production
Database adapter MySQL
Redmine plugins:
due_date_reminder 0.3.1
#29 Updated by Toshi MARUYAMA 24 days ago
David Dupont wrote:
Some help please ?
Use -p1 instead of -p0.
patch -p1 < gantt-sort-trunk-r11744.diff
And this patch is for trunk r11744, not 2.3.0.
#30 Updated by David Dupont 23 days ago
Thanks for the answer !
So i can't install it ?
Even if i change the file manually ? Is there too many difference between the trunk and 2.3.0 ?
#31 Updated by Toshi MARUYAMA 23 days ago
#32 Updated by Toshi MARUYAMA 8 days ago
- File gantt-sort-trunk-r11856.diff
added
This is patch for trunk.
There is no logic change from note-26 patch.
#33 Updated by Toshi MARUYAMA 4 days ago
- Target version set to 2.4.0
- % Done changed from 0 to 100