Forums » Development »
What is lft in table issue of redmine
Added by anhkhoa Michel almost 10 years ago
issue_list(issue.descendants.visible.sort_by(&:lft)) do |child, level|, in issue_helper. But I do'nt undertand why redmine sort_by(&:lft)
Replies (6)
RE: What is lft in table issue of redmine - Added by Jan Niggemann (redmine.org team member) almost 10 years ago
Google "binary tree"...
RE: What is lft in table issue of redmine - Added by Felix Schäfer almost 10 years ago
Binary trees are also very interesting, but don't apply here as the nested set model used by Redmine is not a binary tree at all.
Issues in Redmine can be put in a tree structure, but tree structures are not easily stored in SQL. One way to store trees in SQL is called nested set, which is the way Redmine stores trees in SQL.
Regarding your specific question, I think the examples in the Wikipedia page linked above and this article by Mark Hillyer (look for "The Nested Set Model" and "Retrieving a Full Tree" within that) should answer it. You need to sort your the results of your query by lft
to make sure that all the childs of a given parent immediately follow that parent.
RE: What is lft in table issue of redmine - Added by Jan Niggemann (redmine.org team member) almost 10 years ago
... and I had always thought that a nested set always represented a binary tree...
RE: What is lft in table issue of redmine - Added by anhkhoa Michel almost 10 years ago
But I want sort by with rank of issue.Rank is new column which I add into table issue.
Example: Issue A(id = 1, rank = 2) has two sub issue:issue a1(id=2, rank = 2), issue a2(id:3 rank 1); Issue B(id = 4, rank = 1).in current, (issue.descendants.visible.sort_by(&:lft)) =>[A,a1,a2,B]
I wan to sort with rank not id: B,A,a2,a1
I canno't find solution to resolve my problem!!!Please help me!Thanks all!
RE: What is lft in table issue of redmine - Added by Felix Schäfer almost 10 years ago
You cannot sort by lft
/ in a tree and another column in a simple query. I'm not sure what you'd need to query to get that.
RE: What is lft in table issue of redmine - Added by anhkhoa Michel almost 10 years ago
Who can help me! Please!!!