Opened 13 years ago
Last modified 12 years ago
#9300 assigned defect
Tickets with parent don't layout chronologically
Reported by: | Ryan J Ollos | Owned by: | Chris Nelson |
---|---|---|---|
Priority: | normal | Component: | TracJsGanttPlugin |
Severity: | normal | Keywords: | |
Cc: | falkb | Trac Release: | 0.11 |
Attachments (2)
Change History (22)
Changed 13 years ago by
Attachment: | TicketsWithParentDontLayoutCorrectly.png added |
---|
comment:1 Changed 13 years ago by
Cc: | falkb added; anonymous removed |
---|
comment:2 Changed 13 years ago by
comment:3 Changed 13 years ago by
I have a working fix for this, but I'm hoping you can come up with something cleaner. If you ignore the first part where I just copied and pasted your _compare tickets function, the change is to sort the list of child ticket ids chronologically.
Index: 0.11/tracjsgantt/tracjsgantt.py =================================================================== --- 0.11/tracjsgantt/tracjsgantt.py (revision 10838) +++ 0.11/tracjsgantt/tracjsgantt.py (working copy) @@ -446,6 +446,28 @@ # WBS is a list like [ 2, 4, 1] (the first child of the fourth # child of the second top-level element). def _compute_wbs(self): + def _compare_tickets(t1, t2): + # If t2 depends on t1, t2 is first + if self.fields['succ'] and \ + str(t1['id']) in t2[self.fields['succ']]: + return 1 + # If t1 depends on t2, t1 is first + elif self.fields['succ'] and \ + str(t2['id']) in t1[self.fields['succ']]: + return -1 + # If t1 ends first, it's first + elif t1['calc_finish'] < t2['calc_finish']: + return -1 + # If t2 ends first, it's first + elif t1['calc_finish'] > t2['calc_finish']: + return 1 + # End dates are same. If t1 starts later, it's later + elif t1['calc_start'] > t2['calc_start']: + return 1 + # Otherwise, preserve order (assume t1 is before t2 when called) + else: + return 0 + # Set the ticket's level and wbs then recurse to children. def _setLevel(id, wbs, level): # Update this node @@ -453,10 +475,15 @@ self.ticketsByID[id]['wbs'] = copy.copy(wbs) # Recurse to children - if self.ticketsByID[id]['children']: + childIDs = self.ticketsByID[id]['children'] + if childIDs: + childTickets = [self.ticketsByID[id] for id in childIDs] + childTickets.sort(_compare_tickets) + childIDs = [ct['id'] for ct in childTickets] + # Add another level wbs.append(1) - for c in self.ticketsByID[id]['children']: + for c in childIDs: wbs = _setLevel(c, wbs, level+1) # Remove the level we added wbs.pop()
comment:4 Changed 13 years ago by
I've pushed this patch onto my BitBucket clone:
https://bitbucket.org/rjollos/tracjsganttplugin/changeset/70cd530cc5f5
Changed 13 years ago by
Attachment: | ChildTasksLayingOutCorrectly.png added |
---|
comment:6 Changed 13 years ago by
comment:7 Changed 13 years ago by
Status: | new → assigned |
---|
comment:9 Changed 13 years ago by
(In [11079]) Cleaner date adjustment using calendarOffset. Refs #9533, #9300, #9042, #9515.
Scheduler used to assume work week. Now let calendarOffset() do that.
Also, it seems rounding errors would creep in and some datetimes would have non-zero microseconds. This tests for beginning and end of day with a little delta.
comment:10 Changed 13 years ago by
comment:11 Changed 13 years ago by
comment:12 Changed 13 years ago by
comment:13 Changed 13 years ago by
comment:14 Changed 13 years ago by
(In [11142]) Correct end-of-day adjustments for ASAP and < 100% effort. Refs #9533, #9300.
When working forward to build an ASAP schedule, partial takes caused the tasks to shift forward more than their scheduled length.
If one resource can work 8 hours per day and another can only work 4, the second resource takes twice as long to complete the same task. But without this clean up, ALAP scheduling took an 8-hour task at 4 hours per day from the end of day 2 to the middle of day 1. With this change, if all available hours are used up, the rest of the day is consumed so that 8-hour task goes from the end of day 2 to the start of day 1.
comment:16 Changed 12 years ago by
comment:17 Changed 12 years ago by
comment:18 Changed 12 years ago by
comment:19 Changed 12 years ago by
comment:20 Changed 12 years ago by
(In [11426]) A tree-aware task sorter. Refs #9833, #9042, #9290, #9300, #9691, #9784.
A task's priority depends on its parent's priority.
Includes a base sorter class to hold common sorter methods.
SimpleSorter and ProjectSorter derive from the base class.
(Copy effective priority list, just in case.)
Also remove unneeded debugging output. Refs #9648.
I'm seeing that the tasks are sorted chronologically, then assigned a wbs (i.e. parent/child relationships) and then sorted again. The second sort won't change the relative ordering of the parents, but the children are re-ordered such that they are no longer chronological. For example, here is the list of wbs values for a particular instance:
The issue seems to be that the children aren't sorted chronologically before assigning a wbs value. One solution might be to sort the list of children chronologically so that the wbs values get assigned chronologically.