Changes between Version 6 and Version 7 of TracIniReportCustomFieldSample
- Timestamp:
- Feb 24, 2007, 2:29:50 AM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracIniReportCustomFieldSample
v6 v7 1 = Report with CustomFields =1 = Report with TracTicketsCustomFields = 2 2 3 3 Here are some examples of how to generate simple custom reports from TracTicketsCustomFields. … … 9 9 Enjoy! 10 10 11 Trac.ini 11 '''Trac.ini:''' 12 12 {{{ 13 13 … … 18 18 }}} 19 19 20 Custom SQL 20 '''Custom SQL:''' 21 21 {{{ 22 22 SELECT 23 milestone as Pro yectos,24 sum(p.value) as Tiempo_Invertido23 milestone as Project, 24 sum(p.value) as Inverted_Time 25 25 FROM ticket t, ticket_custom p 26 26 WHERE p.ticket = t.id and p.name = 'test_one' … … 30 30 }}} 31 31 32 BTW.Sorry my English and short text.33 34 32 35 33 == Example 2 == 36 34 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_customin turn.35 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 custom field in turn. 38 36 37 '''Trac.ini:''' 38 {{{ 39 40 [ticket-custom] 41 charge = text 42 charge.label = Charge 43 44 noncharge = text 45 noncharge.label = Non charge 46 47 sitevisit = text 48 sitevisit.label = Site visit 49 50 oohours = text 51 oohours.label = Hours 52 }}} 53 54 55 '''Custom SQL:''' 39 56 {{{ 40 57 SELECT DISTINCT … … 74 91 I 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%. 75 92 76 So in my trac.ini I added: 77 93 '''trac.ini:''' 78 94 {{{ 79 95 [ticket-custom] … … 85 101 86 102 Then 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:''' 87 105 88 106 {{{ … … 103 121 * the OUTER JOIN is the key to getting this to work 104 122 * I'm not totally fluent in SQL, so this may not be the simplest way, but it works for me 123 124 == Example 4 == 125 I 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] 130 estimate = text 131 estimate.label = Estimate 132 133 actual = text 134 actual.label = Actual 135 }}} 136 137 '''Custom SQL:''' 138 139 {{{ 140 SELECT 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 }}}