views:

147

answers:

2

How do I query for all trac tickets related to a user. i.e. all tickets for which the tickets were once assigned, assigned now, created , etc etc

+2  A: 

Create custom queries to the ticket_change table. Some SQL required. For assigned once/now, look for rows where field='owner', newvalue column contains the user name the ticket was assigned to. For created tickets, just query by reporter in the ticket table.

Example:

SELECT p.value AS __color__,
   id AS ticket, summary, component, version, milestone,
   t.type AS type, priority, t.time AS created,
   changetime AS _changetime, description AS _description,
   reporter AS _reporter
  FROM ticket t, enum p, ticket_change c
  WHERE p.name = t.priority AND p.type = 'priority'
  AND c.field = 'owner'
  AND c.newvalue = '$USER'
  AND c.ticket = t.id
  ORDER BY p.value, milestone, t.type, t.time
laalto
+1  A: 

You can express this with a TraqQuery expression. E.g. if you want the columns id, summary and status to show up and query all the tickets for the currently logged in user ($USER) then use the following query.

query:?col=id
&
col=summary
&
col=status
&
owner=$USER

However this query assumes that the owner hasn't been the same during the lifetime of a ticket (since ownership can be changed).

If you want a specific user then replace $USER with the actual username. Also if you're using the Agilo plugin you can easily create new queries on the fly via the web-UI. This is done by looking at a report and adding filters to the report.

Spoike
This doesn't address the requirement to get tickets that were once assigned to a user.
laalto