| 1 | = Trac Reports = |
| 2 | The Trac reports module provides a simple, yet powerful reporting facility |
| 3 | for presenting information about tickets from the Trac database. |
| 4 | |
| 5 | == Creating Custom Reports == |
| 6 | |
| 7 | Creating a custom report requires knowing and using the SQL query language. |
| 8 | |
| 9 | A report is basically a single named SQL query, executed and presented by |
| 10 | Trac. Reports can be viewed and created from a custom SQL expression directly |
| 11 | in from the web interface. |
| 12 | |
| 13 | Typically, a report consists of a SELECT-expression from the 'ticket' table, |
| 14 | using the available columns and sorting the way you want it. |
| 15 | |
| 16 | == Ticket columns == |
| 17 | The '''ticket'' table has the following columns: |
| 18 | * id |
| 19 | * time |
| 20 | * changetime |
| 21 | * component |
| 22 | * severity |
| 23 | * priority |
| 24 | * owner |
| 25 | * reporter |
| 26 | * cc |
| 27 | * url |
| 28 | * version -- Version of the project does this ticket pertains to. |
| 29 | * milestone |
| 30 | * status |
| 31 | * resolution |
| 32 | * summary |
| 33 | * description |
| 34 | |
| 35 | See TracTickets for a detailed description of the column fields. |
| 36 | |
| 37 | == Special Columns == |
| 38 | To format the report properly, Trac needs to know the meaning of some result |
| 39 | columns . This is a list of column names of special meaning to Trac: |
| 40 | * '''ticket''' -- Ticket ID number. Will become a hyperlink to that ticket. |
| 41 | |
| 42 | ''Note: In upcoming releases, there will be more special columns added, to create color-coded reports, grouping and other nifty features.'' |
| 43 | |
| 44 | |
| 45 | |
| 46 | == Sample Reports == |
| 47 | '''status and summary for all tickets''' |
| 48 | |
| 49 | {{{ |
| 50 | SELECT id as ticket, status, summary FROM ticket |
| 51 | }}} |
| 52 | |
| 53 | ---- |
| 54 | '''all active tickets, sorted by priority and time''' |
| 55 | |
| 56 | {{{ |
| 57 | SELECT id AS ticket, status, severity, priority, owner, |
| 58 | time as created, summary FROM ticket |
| 59 | WHERE status IN ('new', 'assigned', 'reopened') |
| 60 | ORDER BY priority, time |
| 61 | }}} |
| 62 | |
| 63 | ---- |
| 64 | '''active tickets, grouped by milestone and sorted by priority''' |
| 65 | |
| 66 | {{{ |
| 67 | SELECT id AS ticket, milestone, status, severity, |
| 68 | priority, component, owner, summary |
| 69 | FROM ticket |
| 70 | WHERE status IN ('new', 'assigned', 'reopened') |
| 71 | ORDER BY milestone, |
| 72 | (CASE priority |
| 73 | WHEN 'highest' THEN 0 |
| 74 | WHEN 'high' THEN 1 |
| 75 | WHEN 'normal' THEN 2 |
| 76 | WHEN 'low' THEN 3 |
| 77 | ELSE 4 |
| 78 | END), severity, time |
| 79 | }}} |
| 80 | |
| 81 | |
| 82 | See also: TracTickets, TracGuide |