Edgewall Software

Changes between Version 6 and Version 7 of TracIniReportCustomFieldSample


Ignore:
Timestamp:
Feb 24, 2007, 2:29:50 AM (17 years ago)
Author:
pombredanne@…
Comment:

Fixed some typos, non-english short texts, and reversed engineered some missin trac.ini snippets to make the examples easier to use, and added a new example

Legend:

Unmodified
Added
Removed
Modified
  • TracIniReportCustomFieldSample

    v6 v7  
    1 = Report with CustomFields =
     1= Report with TracTicketsCustomFields =
    22
    33Here are some examples of how to generate simple custom reports from TracTicketsCustomFields.
     
    99Enjoy!
    1010
    11 Trac.ini
     11'''Trac.ini:'''
    1212{{{
    1313
     
    1818}}}
    1919
    20 Custom SQL
     20'''Custom SQL:'''
    2121{{{
    2222SELECT
    23    milestone as Proyectos,
    24    sum(p.value) as Tiempo_Invertido
     23   milestone as Project,
     24   sum(p.value) as Inverted_Time
    2525   FROM ticket t, ticket_custom p
    2626   WHERE p.ticket = t.id and p.name = 'test_one'
     
    3030}}}
    3131
    32 BTW.Sorry my English and short text.
    33 
    3432
    3533== Example 2 ==
    3634
    37 Here's another longer example ... I have four fields in my ticket_custom, and I want them all to be seen in the report. If the existing field was a NULL, the report code adds the word "None" to the output, so I'm getting rid of that with a CASE statement. The main magic is the series of LEFT OUTER JOINs, which let me access each field of ticket_custom in turn.
     35Here's another longer example ... I have four fields in my ticket-custom, and I want them all to be seen in the report. If the existing field was a NULL, the report code adds the word "None" to the output, so I'm getting rid of that with a CASE statement. The main magic is the series of LEFT OUTER JOINs, which let me access each custom field in turn.
    3836
     37'''Trac.ini:'''
     38{{{
     39
     40[ticket-custom]
     41charge = text
     42charge.label = Charge
     43
     44noncharge = text
     45noncharge.label = Non charge
     46
     47sitevisit = text
     48sitevisit.label = Site visit
     49
     50oohours = text
     51oohours.label = Hours
     52}}}
     53
     54
     55'''Custom SQL:'''
    3956{{{
    4057SELECT DISTINCT
     
    7491I added a custom ticket field to provide an idea of the percentage of the ticket completed so far.  This is a simple dropdown list where the developer can log their progress to the nearest 20%.
    7592
    76 So in my trac.ini I added:
    77 
     93'''trac.ini:'''
    7894{{{
    7995[ticket-custom]
     
    85101
    86102Then to generate a simple report containing the new field, based on the default 'Active Tickets' report, I ended up with this:
     103
     104'''Custom SQL:'''
    87105
    88106{{{
     
    103121 * the OUTER JOIN is the key to getting this to work
    104122 * I'm not totally fluent in SQL, so this may not be the simplest way, but it works for me
     123
     124== Example 4 ==
     125I have added a few custom fields to track roughly the amount of work spent on each ticket. One field is the estimated work (in days) and the iother is the actual work (in days). I needed a simple report to summarize the total amount of work for each milestone: estimated and actual.
     126
     127'''trac.ini:'''
     128{{{
     129[ticket-custom]
     130estimate = text
     131estimate.label = Estimate
     132
     133actual = text
     134actual.label = Actual
     135}}}
     136
     137'''Custom SQL:'''
     138
     139{{{
     140SELECT
     141   milestone AS Iteration,
     142   SUM(estimate.value) AS Estimate,
     143   SUM(actual.value) AS Actual
     144
     145  FROM ticket t
     146
     147  LEFT OUTER JOIN ticket_custom estimate ON
     148       (t.id=estimate.ticket AND estimate.name='estimate')
     149
     150  LEFT OUTER JOIN ticket_custom actual ON
     151       (t.id=actual.ticket AND actual.name='actual')
     152
     153  GROUP BY milestone
     154
     155}}}