Edgewall Software
Home
Trac
Trac Hacks
Genshi
Babel
Bitten
Home
Download
Documentation
Mailing Lists
License
FAQ
Search:
Login
Preferences
Help/Guide
About Trac
Wiki
Timeline
Roadmap
Browse Source
View Tickets
New Ticket
Search
Context Navigation
+0
Start Page
Index
History
Editing TracDev/PluginDevelopment/ExtensionPoints/trac.ticket.roadmap.ITicketGroupStatsProvider
Adjust edit area height:
8
12
16
20
24
28
32
36
40
Edit side-by-side
== Extension Point : ''ITicketGroupStatsProvider'' == ||'''Interface'''||''ITicketGroupStatsProvider''||'''Since'''||[wiki:TracDev/ApiChanges/0.11#ITicketGroupStatsProvider 0.11]|| ||'''Module'''||''trac.ticket.roadmap''||'''Source'''||[source:trunk/trac/ticket/roadmap.py#/ITicketGroupStatsProvider roadmap.py]|| The ''ITicketGroupStatsProvider'' allows components to provide alternate ways to compute Milestone statistics. == Purpose == The [TracRoadmap roadmap] provides a view on the [TracTickets ticket] milestones with aggregated group statistics displayed as a milestone progress bar. The default grouping simply shows the ratio between active and resolved tickets. It is possible to [TracRoadmapCustomGroups customise] the ticket grouping and have multiple ticket statuses shown on the progress bar. Plugins can further customize the roadmap system to modify the milestone completion progress bars by changing the way ticket statistics are collected. The main purpose for this interface is to allow plugins to incorporate more information into the milestone completion calculations (e.g. tracked hours). Note that for simply having more ticket groups displayed, a change of [TracIni#milestone-groups-section configuration] is enough and no new plugin is needed. == Usage == Implementing the interface follows the standard guidelines found in [wiki:TracDev/ComponentArchitecture] and of course [wiki:TracDev/PluginDevelopment]. The component has to be configured as the [TracIni#milestone-section "[milestone]"] `stats_provider` (to use it when viewing individual milestones) and / or the [TracIni#roadmap-section "[roadmap]"] `stats_provider` (to use it when viewing the roadmap). Trac then automatically calls the `get_ticket_group_stats` method to retrieve a `TicketGroupStats` object for a given group of tickets. Typically this consists of these steps: * Create a new instance by calling `stat = TicketGroupStats(title, unit)` where: * `title` is the title of the statistic (e.g. `'ticket status'` as in ''Ticket status by milestone''). * `unit` is the name of the unit for the statistic (e.g. `'tickets'` as in ''Total number of tickets'', or `'hours'` as in ''Total number of hours''). * Calculate some statistics e.g. by quering the database. * Add intervalls to make up the progress bar by calling `stat.add_interval(title, count, qry_args, css_class, overall_completion=None)` where: * `title` is the name of this interval displayed in front of the unit name (e.g. `'closed'`) as in ''Close tickets''). * `count` is the number of units in this interval. * `qry_args` is a dict of extra parameters used in a TracQuery to link to tickets in this interval. * `css_class` is the css class that will be used to display this interval. * `overall_completion` can optionally be set to `True` to make this interval count towards overall completion of this group of tickets. * Call `stat.refresh_calcs()` to calculate the interval percentages so they add up to 100%, and then `return stat`. == Examples == Projects might for some reason want to group tickets and see progress by ''ticket owner'', and count only those tickets as completed where the owner is done with ''all'' tickets: {{{#!python from trac.core import Component, implements from trac.ticket.roadmap import ITicketGroupStatsProvider, TicketGroupStats class TicketOwnerGroupStats(Component): implements(ITicketGroupStatsProvider) def get_ticket_group_stats(self, ticket_ids): total_cnt = len(ticket_ids) stat = TicketGroupStats('ticket owner', 'tickets') if total_cnt: for owner, count, closed in self.env.db_query(""" SELECT owner, count(owner), SUM(CASE WHEN status = 'closed' THEN 1 ELSE 0 END) as closed FROM ticket WHERE id IN (%s) GROUP BY owner """ % ",".join(str(x) for x in sorted(ticket_ids))): label = owner query_args = {'owner': [owner]} css_class = owner stat.add_interval(label, count, query_args, css_class, count == closed) stat.refresh_calcs() return stat }}} == Available Implementations == * `trac.ticket.roadmap.DefaultTicketGroupStatsProvider`: * th:RoadmapHoursPlugin: Shows intervals ''Worked hours'' and ''Remaining hours''. * th:SumStatsPlugin: Sums up a configurable custom ticket field. * th:CustomRoadmapPlugin: Automatically customizes CSS. == Additional Information and References == * [apiref:trac.ticket.roadmap.ITicketGroupStatsProvider-class epydoc] * [apidoc:api/trac_ticket_roadmap#trac.ticket.roadmap.ITicketGroupStatsProvider API Reference] * Related tickets: * #6232 refactor `DefaultTicketGroupStatsProvider` so subclasses could easily reuse some parts of its logic. * #1534 weighted tickets for progress bar. * Archived discussions: * [Trac-ML:5084 Discussions] [Trac-ML:5099 during] [Trac-ML:5212 development] === API History * [wiki:TracDev/ApiChanges/0.11#ITicketGroupStatsProvider 0.11] introduced the interface (#2314) * 0.12 [changeset:10661 removed] the [changeset:6011 deprecated] `countsToProg` argument to `TicketGroupStats.add_interval()`.
Note:
See
WikiFormatting
and
TracWiki
for help on editing wiki content.
Change information
Your email or username:
E-mail address and name can be saved in the
Preferences
Comment about this change (optional):
Note:
See
TracWiki
for help on using the wiki.