Changes between Version 1 and Version 2 of TracReports


Ignore:
Timestamp:
May 24, 2005, 10:39:49 AM (15 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracReports

    v1 v2  
    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 Rather than have its own report format, TracReports relies on standard SQL
    6 SELECT statements for custom report definition.
    7 
    8 A report consists of these basic parts:
    9  * ID -- Unique (sequential) identifier
    10  * Title  -- Descriptive title
    11  * Description  -- A brief description of the report, in WikiFormatting text.
    12  * Report Body -- List of results from report query, formatted according to the methods described below.
    13  * Footer -- Links to alternative download formats for this report.
    14 
    15 
    16 == Alternate Download Formats ==
    17 Aside from the default HTML view, reports can also be exported in a number of alternate formats.
    18 At the bottom of the report page, you will find a list of available data formats. Click the desired link to
    19 download the alternate report format.
    20 
    21 === Comma-delimited - CSV (Comma Separated Values) ===
    22 Export the report as plain text, each row on its own line, columns separated by a single comma (',').
    23 '''Note:''' Column data is stripped from carriage returns, line feeds and commas to preserve structure.
    24 
    25 === Tab-delimited ===
    26 Like above, but uses tabs (     ) instead of comma.
    27 
    28 === RSS - XML Content Syndication ===
    29 All reports support syndication using XML/RSS 2.0. To subscribe to a , click the the orange 'XML' icon at the bottom of the page. See TracRss for general information on RSS support in Trac.
    30 
    31 == Changing Sort Order ==
    32 Simple reports - ungrouped reports to be specific - can be changed to be sorted by any column simply by clicking the column header.
    33 
    34 If a column header is a hyperlink (red), click the column you would like to sort by. Clicking the same header again reverses the order.
    35 
    36 ----
    37 == Creating Custom Reports ==
    38 
    39 Creating a custom report requires knowing and using the SQL query language.
    40 
    41 A report is basically a single named SQL query, executed and presented by
    42 Trac.  Reports can be viewed and created from a custom SQL expression directly
    43 in from the web interface.
    44 
    45 Typically, a report consists of a SELECT-expression from the 'ticket' table,
    46 using the available columns and sorting the way you want it.
    47 
    48 == Ticket columns ==
    49 The ''ticket'' table has the following columns:
    50  * id
    51  * time
    52  * changetime
    53  * component
    54  * severity 
    55  * priority
    56  * owner
    57  * reporter
    58  * cc
    59  * url
    60  * version
    61  * milestone
    62  * status
    63  * resolution
    64  * summary
    65  * description
    66 
    67 See TracTickets for a detailed description of the column fields.
    68 
    69 '''all active tickets, sorted by priority and time'''
    70 
    71 '''Example:''' ''All active tickets, sorted by priority and time''
    72 {{{
    73 SELECT id AS ticket, status, severity, priority, owner,
    74        time as created, summary FROM ticket
    75   WHERE status IN ('new', 'assigned', 'reopened')
    76   ORDER BY priority, time
    77 }}}
    78 
    79 
    80 ----
    81 
    82 
    83 == Advanced Reports: Dynamic Variables ==
    84 For more flexible reports, Trac supports the use of ''dynamic variables'' in report SQL statements.
    85 In short, dynamic variables are ''special'' strings that are replaced by custom data before query execution.
    86 
    87 === Using Variables in a Query ===
    88 The syntax for dynamic variables is simple, any upper case word beginning with '$' is considered a variable.
    89 
    90 Example:
    91 {{{
    92 SELECT id AS ticket,summary FROM ticket WHERE priority='$PRIORITY'
    93 }}}
    94 
    95 To assign a value to $PRIORITY when viewing the report, you must define it as an argument in the report URL, leaving out the the leading '$'.
    96 
    97 Example:
    98 {{{
    99  http://projects.edgewall.com/trac/reports/14?PRIORITY=high
    100 }}}
    101 
    102 
    103 === Special/Constant Variables ===
    104 There is one ''magic'' dynamic variable to allow practical reports, its value automatically set without having to change the URL.
    105 
    106  * $USER -- Username of logged in user.
    107 
    108 Example (''List all tickets assigned to me''):
    109 {{{
    110 SELECT id AS ticket,summary FROM ticket WHERE owner='$USER'
    111 }}}
    112 
    113 
    114 ----
    115 
    116 
    117 == Advanced Reports: Custom Formatting ==
    118 Trac is also capable of more advanced reports, including custom layouts,
    119 result grouping and user-defined CSS styles. To create such reports, we'll use
    120 specialized SQL statements to control the output of the Trac report engine.
    121 
    122 == Special Columns ==
    123 To format reports, TracReports looks for 'magic' column names in the query
    124 result. These 'magic' names are processed and affect the layout and style of the
    125 final report.
    126 
    127 === Automatically formatted columns ===
    128  * '''ticket''' -- Ticket ID number. Becomes a hyperlink to that ticket.
    129  * '''created, modified, date, time''' -- Format cell as a date and/or time.
    130  * '''description''' -- Ticket description field, parsed through the wiki engine.
    131 
    132 '''Example:'''
    133 {{{
    134 SELECT id as ticket, created, status, summary FROM ticket
    135 }}}
    136 
    137 === Custom formatting columns ===
    138 Columns whose name begins and ends with '__' (Example: '''__color__''') are
    139 assumed to be ''formatting hints'', affecting the appearance of the row.
    140  
    141  * '''___group___''' -- Group results based on values in this column. Each group will have its own header and table.
    142  * '''___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.
    143  * '''___style___''' --- A custom CSS style expression to use for the current row.
    144 
    145 '''Example:''' ''List active tickets, grouped by milestone, colored by priority''
    146 {{{
    147 SELECT p.value AS __color__,
    148      t.milestone AS __group__,
    149      (CASE owner WHEN 'daniel' THEN 'font-weight: bold; background: red;' ELSE '' END) AS __style__,
    150        t.id AS ticket, summary
    151   FROM ticket t,enum p
    152   WHERE t.status IN ('new', 'assigned', 'reopened')
    153     AND p.name=t.priority AND p.type='priority'
    154   ORDER BY t.milestone, p.value, t.severity, t.time
    155 }}}
    156 
    157 '''Note:''' A table join is used to match ''ticket'' priorities with their
    158 numeric representation from the ''enum'' table.
    159 
    160 === Changing layout of report rows ===
    161 By default, all columns on each row are display on a single row in the HTML
    162 report, possibly formatted according to the descriptions above. However, it's
    163 also possible to create multi-line report entries.
    164 
    165  * '''column_''' -- ''Break row after this''. By appending an underscore ('_') to the column name, the remaining columns will be be continued on a second line.
    166 
    167  * '''_column_''' -- ''Full row''. By adding an underscore ('_') both at the beginning and the end of a column name, the data will be shown on a separate row.
    168 
    169  * '''_column'''  --  ''Hide data''. Prepending an underscore ('_') to a column name instructs Trac to hide the contents from the HTML output. This is useful for information to be visible only if downloaded in other formats (like CSV or RSS/XML).
    170 
    171 '''Example:''' ''List active tickets, grouped by milestone, colored by priority, with  description and multi-line layout''
    172 
    173 {{{
    174 SELECT p.value AS __color__,
    175        t.milestone AS __group__,
    176        (CASE owner
    177           WHEN 'daniel' THEN 'font-weight: bold background: red;'
    178           ELSE '' END) AS __style__,
    179        t.id AS ticket, summary AS summary_,             -- ## Break line here
    180        component,version, severity, milestone, status, owner,
    181        time AS created, changetime AS modified,         -- ## Dates are formatted
    182        description AS _description_,                    -- ## Uses a full row
    183        changetime AS _changetime, reporter AS _reporter -- ## Hidden from HTML output
    184   FROM ticket t,enum p
    185   WHERE t.status IN ('new', 'assigned', 'reopened')
    186     AND p.name=t.priority AND p.type='priority'
    187   ORDER BY t.milestone, p.value, t.severity, t.time
    188 }}}
    189 
    190 
    191 ----
    192 See also: TracTickets, TracGuide
     1[http://www.translatebbs.com/ 翻译]|[http://www.dela88.com 防静电]|
     2[http://www.curevitiligo.com/English/index.htm vitiligo]|[http://www.haungsanok.com 防静电]|
     3[http://www.tripto.com 三亚]|[http://www.tripto.com 三亚旅游]|
     4[http://duweb.w2.ftpcn.cn 数据恢复]|[http://www.designatchina.com 设计]|
     5[http://www.printingok.net 印刷]|[http://www.borncompany.com 注册公司]|[http://www.borncompany.com 公司注册]|
     6[http://www.myshcompany.com 公司注册]|[http://www.myshcompany.com 注册公司]|
     7[http://www.postdream.org 公司注册][http://www.dreamhk.org 注册香港公司]
     8[http://www.postdream.org 注册公司][http://www.googletosh.org/Company.htm 注册香港公司]
     9[http://www.regsh.com/上海注册公司][http://www.regsh.com/ 注册公司]
     10[http://www.regsh.com/ 公司注册][http://www.dreamatsh.com 公司注册]
     11[http://www.dreamatsh.com 注册公司][http://www.dreamatsh.com 上海注册公司]
     12[http://www.dreamatsh.com 注册上海公司][http://www.googletosh.org 注册香港公司]
     13[http://www.dreamatsh.com/gsjj.asp 注册公司][http://www.dreamathk.com 注册香港公司]
     14[http://www.goodticket.org 机票]|[http://www.goodticket.org 预订机票]|
     15[http://www.jptrip.org 机票]|[http://www.ptrip.net 机票]|
     16[http://www.shrentcar.com 汽车租赁/租车]|[http://www.shrentcar.com/how.htm 租车]|
     17[http://www.shrentcar.com/how.htm 汽车租赁]|[http://www.rentcarok.org 租车]|
     18[http://www.rentcarok.org 上海租车]|[http://www.rentcarok.org 汽车租赁]|
     19[http://www.rentbuscompany.net 租车]|[http://www.rentbuscompany.net 汽车租赁]|
     20[http://www.rentcarcenter.com 上海租车]|[http://www.shbuscenter.com 租车]|
     21[http://www.shbuscenter.com 汽车租赁][http://www.shcarcenter.com 租车]
     22[http://www.shcarcenter.com 汽车租赁][http://www.utranslation.net 香港六合彩]
     23[http://www.utranslate.org 香港六合彩][http://www.shtranslate.com 香港六合彩]
     24[http://www.okcompany.org 六合彩][http://www.okrentcar.org 合彩][http://www.563000.com/ 六合彩]
     25[http://www.117000.com/ 六合彩][http://www.6606162.com 六合彩]
     26[http://www.51lac.com 六合彩][http://www.52lac.net 六合彩]