Project

General

Profile

Actions

Defect #7335

closed

Sorting issues in gantt by date, not by id

Added by Eli Stevens almost 14 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Toshi MARUYAMA
Category:
Gantt
Target version:
Start date:
2011-01-15
Due date:
% Done:

90%

Estimated time:
Resolution:
Fixed
Affected version:

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:

  1. 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.


Files

sort_issues_from_start_date.diff (1.55 KB) sort_issues_from_start_date.diff Felipe Ribeiro, 2011-12-05 20:03
sort_issues.rb (782 Bytes) sort_issues.rb Felipe Ribeiro, 2011-12-05 20:03
redmine-trunk-r10713.png (21.5 KB) redmine-trunk-r10713.png Toshi MARUYAMA, 2012-10-24 15:32
redmine-trunk-r10713-patch.png (39.6 KB) redmine-trunk-r10713-patch.png Toshi MARUYAMA, 2012-10-24 15:32
gantt-sort-r10713.diff (1.16 KB) gantt-sort-r10713.diff Toshi MARUYAMA, 2012-10-24 15:32
gantt-sort-trunk-r11692.diff (1.78 KB) gantt-sort-trunk-r11692.diff Toshi MARUYAMA, 2013-03-31 08:51
gantt-sort-trunk-r11692.png (20 KB) gantt-sort-trunk-r11692.png Toshi MARUYAMA, 2013-03-31 08:51
gantt-sort-trunk-r11723.diff (3.12 KB) gantt-sort-trunk-r11723.diff Toshi MARUYAMA, 2013-04-19 07:02
gantt.jpg (65.4 KB) gantt.jpg Yuhki ISHIGURO, 2013-04-22 02:55
gantt-sort-trunk-r11740.diff (3.09 KB) gantt-sort-trunk-r11740.diff Toshi MARUYAMA, 2013-04-22 09:34
gantt-sort-trunk-r11744.diff (4.04 KB) gantt-sort-trunk-r11744.diff Toshi MARUYAMA, 2013-04-23 17:44
gantt-sort-trunk-r11856.diff (2.34 KB) gantt-sort-trunk-r11856.diff Toshi MARUYAMA, 2013-05-18 01:36
gantt-sort-version-trunk-r11898.diff (438 Bytes) gantt-sort-version-trunk-r11898.diff Filou Centrinov, 2013-07-15 19:06

Related issues

Related to Redmine - Patch #5438: Patch repairing rendering of subtasks in gantt diagram Closed2010-05-042010-05-04

Actions
Related to Redmine - Patch #7456: Gantt filtersNew2011-01-26

Actions
Related to Redmine - Feature #6276: Gantt Chart rewriteClosedEric Davis2010-09-03

Actions
Related to Redmine - Patch #12730: Fix sorting and PDF output of Gantt diagram & start date calculation and groupingNewJean-Philippe Lang

Actions
Related to Redmine - Defect #7128: New gantt chart does not render subtasks under parent taskClosed2010-12-18

Actions
Related to Redmine - Feature #8897: Be able to reorder tasks/issues in the Gantt chartNew2011-07-25

Actions
Related to Redmine - Defect #7579: Gantt tab gives internal error.Closed2011-02-08

Actions
Related to Redmine - Feature #14397: Gantt sorting as a configurable settingNew

Actions
Has duplicate Redmine - Feature #7968: Order tasks by time on GanntClosed

Actions
Has duplicate Redmine - Defect #8480: gantt sorting in redmine 1.2Closed2011-05-31

Actions
Has duplicate Redmine - Feature #13238: Sorting in GanttClosed

Actions
Has duplicate Redmine - Defect #6968: Sorting of issues in GanttClosed2010-11-24

Actions
Has duplicate Redmine - Defect #8366: Gantt Version OrderingClosed2011-05-13

Actions
Actions #1

Updated by Eli Stevens almost 14 years ago

Hum, apparently I can't add related issues. They should be:
#5438
#6968

Actions #2

Updated by Guillaume Pellegrin almost 14 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

Actions #3

Updated by Eli Stevens almost 14 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]
Actions #4

Updated by Sebastian Buckpesch almost 14 years ago

Hi,
where do I enter this line of code or apply this patch?

Thanks,
Sebastian

Actions #5

Updated by Etienne Massip almost 14 years ago

lib/redmine/helpers/gantt_helper.rb (gantt_issue_compare()) ?

Actions #6

Updated by Sebastian Buckpesch almost 14 years ago

thanks. Works fine.

Actions #7

Updated by E M almost 14 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.

Actions #8

Updated by Fernando Hartmann over 13 years ago

+1

Actions #9

Updated by Carlos Serrano over 13 years ago

thanks. Works fine.

Actions #10

Updated by Cassiano Monteiro over 13 years ago

+1

Actions #11

Updated by Lukas Elmer about 13 years ago

+1, related with #8480

Actions #12

Updated by Felipe Ribeiro almost 13 years ago

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.

Actions #14

Updated by lmerl andeson over 12 years ago

  • Assignee set to Mischa The Evil
Actions #15

Updated by Toshi MARUYAMA about 12 years ago

  • Assignee deleted (Mischa The Evil)
Actions #16

Updated by Toshi MARUYAMA about 12 years ago

This is a patch for trunk r10713.

This patch sort start date algorism is referred from Redmine Better Gantt Chart Plugin

https://github.com/kulesa/redmine_better_gantt_chart/blob/50c323fe8b6ac667c88b/lib/redmine/helpers/better_gantt.rb#L692

But, issues tree structure is broken by start date sorting.

Redmine trunk r10713

Patch applied

Actions #17

Updated by Etienne Massip about 12 years ago

FTR the patch in #7456 originally implemented some sorting too.

Actions #18

Updated by Jonathan Vargas almost 12 years 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.

Actions #19

Updated by Toshi MARUYAMA almost 12 years ago

New patch is posted at #8366#note-2.

Actions #21

Updated by Yuhki ISHIGURO over 11 years 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.

Actions #22

Updated by Toshi MARUYAMA over 11 years ago

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

Actions #23

Updated by Yuhki ISHIGURO over 11 years ago

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.

Actions #24

Updated by Toshi MARUYAMA over 11 years ago

I got a suggestion from patch author.
https://twitter.com/nobu_toyofuku/status/326227862808064000

Could you try this patch?

Actions #25

Updated by Yuhki ISHIGURO over 11 years ago

I tried gantt-sort-trunk-r11740.diff, and it seems working correctly!
Thank you !!

Regards,
Yuhki ISHIGURO

Actions #26

Updated by Toshi MARUYAMA over 11 years ago

gantt-sort-trunk-r11740.diff does not sort root issues.
This patch fixes it.

Actions #27

Updated by Yuhki ISHIGURO over 11 years 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

Actions #28

Updated by David Dupont over 11 years 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

Actions #29

Updated by Toshi MARUYAMA over 11 years 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.

Actions #30

Updated by David Dupont over 11 years 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 ?

Actions #31

Updated by Toshi MARUYAMA over 11 years ago

David Dupont wrote:

Is there too many difference between the trunk and 2.3.0 ?

There is no difference between trunk r11768 and 2.3-stable r11769 for this patch.
You can apply this patch to 2.3-stable.

Actions #32

Updated by Toshi MARUYAMA over 11 years ago

This is patch for trunk.
There is no logic change from note-26 patch.

Actions #33

Updated by Toshi MARUYAMA over 11 years ago

  • Target version set to 2.4.0
  • % Done changed from 0 to 100
Actions #34

Updated by Toshi MARUYAMA over 11 years ago

  • Related to Defect #7579: Gantt tab gives internal error. added
Actions #35

Updated by Toshi MARUYAMA over 11 years ago

  • Related to Feature #14397: Gantt sorting as a configurable setting added
Actions #36

Updated by Filou Centrinov over 11 years ago

Please correct sort_version_logic(). Only "version.effective_date" contains the start date of a version. Otherwise the versions won't sorted by start date as expected.

Actions #37

Updated by Filou Centrinov over 11 years ago

  • % Done changed from 100 to 90
Actions #38

Updated by Mischa The Evil about 11 years ago

  • Assignee set to Toshi MARUYAMA

Filou Centrinov wrote:

Please correct sort_version_logic(). Only "version.effective_date" contains the start date of a version. Otherwise the versions won't sorted by start date as expected.

Toshi, can you look into this? Seems there might be something wrong with the tests because this does not trigger test failures.

Actions #39

Updated by Jean-Philippe Lang about 11 years ago

  • Target version changed from 2.4.0 to Candidate for next major release

2.4 feature freeze

Actions #40

Updated by Toshi MARUYAMA about 11 years ago

  • Target version changed from Candidate for next major release to 2.4.0

I think note 36 patch need to check in 2.4.0.

Actions #41

Updated by Jean-Philippe Lang about 11 years ago

Filou Centrinov wrote:

Please correct sort_version_logic(). Only "version.effective_date" contains the start date of a version. Otherwise the versions won't sorted by start date as expected.

A better option would be to sort versions by version.effective_date || version.start_date. A version may not have an effective_date but some issues with start dates assigned to it.

Versions with no start_date nor effective should be listed at the very end. I'm not this is the case with || Date.new.

Actions #42

Updated by Etienne Massip about 11 years ago

If it can help, here's an excerpt from #7456 where the idea was also to display shared version before concerned projects:

The shared version is tied to the selected project (also valid for "all projects" Gantt):

parent project -> shared version -> subproject -> shared version issues (including parent project issues)

The shared version is tied to a not-visible-parent project of the selected project:

subproject -> shared version  -> shared version issues (excluding parent project issues)

Issue sorting code within a version+project scope:

      # Compare issues for rendering order 
      def gantt_issue_compare(x, y)
        if x.parent_id == y.parent_id
          # Same level in issue hierarchy
          basic_gantt_issue_compare(x, y)
        elsif x.root_id == y.root_id || x.root_id == y.id || y.root_id == x.id
          # Same issue hierarchy
          x.lft <=> y.lft
        else
          # Distinct hierarchies
          x.root_id <=> y.root_id
          # TODO : advanced sort between issues when ancestors have been filtered out by query
        end
      end

      def basic_gantt_issue_compare(x, y)
        if x.start_date == y.start_date
          x.id <=> y.id
        elsif x.start_date.nil?
          1 # null date appears at the end
        elsif y.start_date.nil?
          -1
        else
          x.start_date <=> y.start_date
        end
      end
Actions #43

Updated by Jean-Philippe Lang almost 11 years ago

  • Subject changed from Sorting issues in new gantt (v1.1.0) to Sorting issues in gantt by date, not by id
  • Status changed from New to Closed
  • Resolution set to Fixed

Toshi MARUYAMA wrote:

I think note 36 patch need to check in 2.4.0.

Versions are now sorted by effective_date (r12247).

Actions

Also available in: Atom PDF