Edgewall Software

Changes between Version 4 and Version 5 of TracReports


Ignore:
Timestamp:
Mar 20, 2004, 9:39:27 PM (17 years ago)
Author:
daniel
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • TracReports

    v4 v5  
    6666
    6767----
     68
     69
     70== Advanced Reports: Dynamic Variables ==
     71For more flexible reports, Trac supports the use of ''dynamic variables'' in report SQL statements.
     72In short, dynamic variables are ''special'' strings that are replaced by custom data before query execution.
     73
     74=== Using Variables in a Query ===
     75The syntax for dynamic variables is simple, any upper case word beginning with '$' is considered a variable.
     76
     77Example:
     78{{{
     79SELECT id AS ticket,summary FROM ticket WHERE priority='$PRIORITY'
     80}}}
     81
     82To 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 '$'.
     83
     84Example:
     85{{{
     86 http://projects.edgewall.com/trac/reports/14?PRIORITY=high
     87}}}
     88
     89
     90=== Special/Constant Variables ===
     91There is one ''magic'' dynamic variable to allow practical reports, its value automatically set without having to change the URL.
     92
     93 * $USER -- Username of logged in user.
     94
     95Example (''List all tickets assigned to me''):
     96{{{
     97SELECT id AS ticket,summary FROM ticket WHERE owner='$USER'
     98}}}
     99
     100
     101----
     102
    68103
    69104== Advanced Reports: Custom Formatting ==
     
    141176
    142177
    143 
    144 ----
    145 
    146 == Sample Reports ==
    147 '''status and summary for all tickets'''
    148 
    149 {{{
    150 SELECT id as ticket, status, summary FROM ticket
    151 }}}
    152 
    153 ----
    154 '''all active tickets, sorted by priority and time'''
    155 
    156 {{{
    157 SELECT id AS ticket, status, severity, priority, owner,
    158        time as created, summary FROM ticket
    159   WHERE status IN ('new', 'assigned', 'reopened')
    160   ORDER BY priority, time
    161 }}}
    162 
    163 ----
    164 '''active tickets, grouped by milestone and sorted by priority'''
    165 
    166 {{{
    167 SELECT id AS ticket, milestone, status, severity,
    168        priority, component, owner, summary
    169   FROM ticket
    170   WHERE status IN ('new', 'assigned', 'reopened')
    171   ORDER BY milestone,
    172     (CASE priority
    173       WHEN 'highest' THEN 0
    174       WHEN 'high' THEN 1
    175       WHEN 'normal' THEN 2
    176       WHEN 'low' THEN 3
    177       ELSE 4
    178     END), severity, time
    179 }}}
    180 
    181 
    182178----
    183179See also: TracTickets, TracGuide