Ticket #1163: trac-0.11-b1-sort-roadmap-by-parent-component.patch

File trac-0.11-b1-sort-roadmap-by-parent-component.patch, 1.6 KB (added by nielx, 16 years ago)

Fix against 0.11-b1

  • trac/ticket/roadmap.py

    diff -r 511085f6ca61 trac/ticket/roadmap.py
    a b def milestone_stats_data(req, stat, name  
    277277        args = {'milestone': name, grouped_by: group, 'group': 'status'}
    278278        args.update(extra_args)
    279279        return req.href.query(args)
     280    if grouped_by == 'component' and group is not None:
     281        group = '^' + group
    280282    return {'stats': stat,
    281283            'stats_href': query_href(stat.qry_args),
    282284            'interval_hrefs': [query_href(interval['qry_args'])
    class MilestoneModule(Component):  
    729731                                       "ORDER BY %s" % (by, by))
    730732                        groups = [row[0] for row in cursor]
    731733
     734            # Special case if we are sorting by component.
     735            if by == 'component':
     736                previous = ''
     737                newgroups = []
     738                for component in groups:
     739                    previous = component.split('/')[0]
     740                    if previous not in newgroups:
     741                        newgroups.append(previous)
     742                groups = newgroups;
     743
    732744            max_count = 0
    733745            group_stats = []
    734746
    735747            for group in groups:
    736                 group_tickets = [t for t in tickets if t[by] == group]
     748                if by != 'component':
     749                    group_tickets = [t for t in tickets if t[by] == group]
     750                else:
     751                    group_tickets = [t for t in tickets if group in t[by]]
    737752                if not group_tickets:
    738753                    continue
    739754