Changes between Version 6 and Version 7 of TracReports
- Timestamp:
- 10/12/21 10:39:25 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracReports
v6 v7 5 5 The Trac reports module provides a simple, yet powerful reporting facility to present information about tickets in the Trac database. 6 6 7 Rather than have its own report definition format, TracReports relies on standard SQL `SELECT` statements for custom report definition. 7 Rather than have its own report definition format, TracReports relies on standard SQL `SELECT` statements for custom report definition. 8 8 9 9 '''Note:''' The report module is being phased out in its current form because it seriously limits the ability of the Trac team to make adjustments to the underlying database schema. We believe that the [wiki:TracQuery query module] is a good replacement that provides more flexibility and better usability. While there are certain reports that cannot yet be handled by the query module, we intend to further enhance it so that at some point the reports module can be completely removed. This also means that there will be no major enhancements to the report module anymore. … … 17 17 18 18 A report consists of these basic parts: 19 * '''ID''' — Unique (sequential) identifier 19 * '''ID''' — Unique (sequential) identifier 20 20 * '''Title''' — Descriptive title 21 21 * '''Description''' — A brief description of the report, in WikiFormatting text. … … 25 25 == Changing Sort Order 26 26 27 Simple reports - ungrouped reports to be specific - can be sorted by clicking the column header. 27 Simple reports - ungrouped reports to be specific - can be sorted by clicking the column header. 28 28 29 29 If a column header is a hyperlink (red), click the column to sort by it. Clicking the same header again reverses the sort order. … … 38 38 39 39 In addition to the HTML view, reports can also be exported in a number of alternate formats. 40 At the bottom of the report page, you will find a list of available data formats. Click the desired link to 40 At the bottom of the report page, you will find a list of available data formats. Click the desired link to 41 41 download the alternate format. 42 42 … … 72 72 * changetime 73 73 * component 74 * severity 75 * priority 74 * severity 75 * priority 76 76 * owner 77 77 * reporter … … 89 89 Example: '''All active tickets, sorted by priority and time''' 90 90 {{{#!sql 91 SELECT id AS ticket, status, severity, priority, owner, time AS created, summary 92 FROM ticket 91 SELECT id AS ticket, status, severity, priority, owner, time AS created, summary 92 FROM ticket 93 93 WHERE status IN ('new', 'assigned', 'reopened') 94 94 ORDER BY priority, time … … 97 97 == Advanced Reports: Dynamic Variables 98 98 99 For more flexible reports, Trac supports the use of ''dynamic variables'' in report SQL statements. 100 In short, dynamic variables are ''special'' strings that are replaced by custom data before query execution. Dynamic variables can also be used in the report title and description //(since 1.1.1)//.99 For more flexible reports, Trac supports the use of ''dynamic variables'' in report SQL statements. 100 In short, dynamic variables are ''special'' strings that are replaced by custom data before query execution. Dynamic variables are entered through the preferences form and the values are autocompleted //(Since 1.3.2)//. 101 101 102 102 === Using Variables in a Query 103 103 104 The syntax for dynamic variables is simple, any upper case word beginning with '$'is considered a variable.104 The syntax for dynamic variables is simple, any upper case word beginning with `$` is considered a variable. 105 105 106 106 Example: … … 109 109 }}} 110 110 111 To assign a value to $PRIORITY when viewing the report, you must define it as an argument in the report URL, leaving out the leading '$': 111 The value of the dynamic variable can be assigned in the report preferences form. 112 113 To assign a value to `$PRIORITY` in the URL for a report, leave out the leading `$`: 112 114 {{{ 113 http ://trac.edgewall.org/reports/14?PRIORITY=high114 }}} 115 116 To use multiple variables, separate them with an '&':115 https://trac.edgewall.org/reports/14?PRIORITY=high 116 }}} 117 118 To use multiple variables, separate them with an `&`: 117 119 {{{ 118 http://trac.edgewall.org/reports/14?PRIORITY=high&SEVERITY=critical 119 }}} 120 https://trac.edgewall.org/reports/14?PRIORITY=high&SEVERITY=critical 121 }}} 122 123 It is possible to assign a default value to the variable, within a SQL comment: 124 125 {{{#!sql 126 -- PRIORITY = high 127 128 SELECT id AS ticket,summary FROM ticket WHERE priority=$PRIORITY 129 }}} 130 120 131 121 132 === !Special/Constant Variables 122 133 123 There is one dynamic variable whose value is set automatically (the URL does not have to be changed) to allow practical reports. 134 There is one dynamic variable whose value is set automatically (the URL does not have to be changed) to allow practical reports. 124 135 125 136 * $USER — Username of logged in user. … … 140 151 === Automatically formatted columns 141 152 142 * '''ticket''' — Ticket ID number. Becomes a hyperlink to that ticket. 153 * '''ticket''' — Ticket ID number. Becomes a hyperlink to that ticket. 143 154 * '''id''' — same as '''ticket''' above when '''realm''' is not set 144 155 * '''realm''' — together with '''id''', can be used to create links to other resources than tickets (e.g. a realm of ''wiki'' and an ''id'' to a page name will create a link to that wiki page) … … 149 160 '''Example:''' 150 161 {{{#!sql 151 SELECT id AS ticket, created, status, summary FROM ticket 162 SELECT id AS ticket, created, status, summary FROM ticket 152 163 }}} 153 164 … … 160 171 Columns whose names begin and end with 2 underscores (e.g. '''`__color__`''') are 161 172 assumed to be ''formatting hints'', affecting the appearance of the row. 162 173 163 174 * '''`__group__`''' — Group results based on values in this column. Each group will have its own header and table. 164 175 * '''`__grouplink__`''' — Make the header of each group a link to the specified URL. The URL is taken from the first row of each group. 165 176 * '''`__color__`''' — Should be a numeric value ranging from 1 to 5 to select a pre-defined row color. Typically used to color rows by issue priority. 166 177 {{{#!html 167 <div style="margin-left:3em">Defaults: 178 <div style="margin-left:3em">Defaults: 168 179 <span style="border: none; color: #333; background: transparent; font-size: 85%; background: #fdc; border-color: #e88; color: #a22">Color 1</span> 169 180 <span style="border: none; color: #333; background: transparent; font-size: 85%; background: #ffb; border-color: #eea; color: #880">Color 2</span> … … 184 195 t.id AS ticket, summary 185 196 FROM ticket t,enum p 186 WHERE t.status IN ('new', 'assigned', 'reopened') 197 WHERE t.status IN ('new', 'assigned', 'reopened') 187 198 AND p.name = t.priority AND p.type = 'priority' 188 199 ORDER BY t.milestone, p.value, t.severity, t.time … … 207 218 SELECT p.value AS __color__, 208 219 t.milestone AS __group__, 209 (CASE owner 210 WHEN 'daniel' THEN 'font-weight: bold; background: red;' 220 (CASE owner 221 WHEN 'daniel' THEN 'font-weight: bold; background: red;' 211 222 ELSE '' END) AS __style__, 212 223 t.id AS ticket, summary AS summary_, -- ## Break line here … … 216 227 changetime AS _changetime, reporter AS _reporter -- ## Hidden from HTML output 217 228 FROM ticket t,enum p 218 WHERE t.status IN ('new', 'assigned', 'reopened') 229 WHERE t.status IN ('new', 'assigned', 'reopened') 219 230 AND p.name = t.priority AND p.type = 'priority' 220 231 ORDER BY t.milestone, p.value, t.severity, t.time … … 242 253 -- ## 4: Assigned, Active Tickets by Owner ## -- 243 254 244 -- 255 -- 245 256 -- List assigned tickets, group by ticket owner, sorted by priority. 246 -- 257 -- 247 258 248 259 SELECT p.value AS __color__, … … 307 318 308 319 ---- 309 See also: TracTickets, TracQuery, [http ://www.sqlite.org/lang_expr.html Query Language Understood by SQLite]320 See also: TracTickets, TracQuery, [https://www.sqlite.org/lang_expr.html Query Language Understood by SQLite]