Question

I use prioritisation for all tickets in Trac. All new tickets have to be prioritized by our Admin user.

While a normal user creates a new ticket, he/she can already prioritize the ticket, but that can be quite arbitrary sometimes. Admin should look through all prioritisations by himself.

Is it possible to select only those tickets, that are not prioritized by Admin himself?


I am quite near already:

-- union tickets initially prioritized by another than Admin and not changed ever since:
 SELECT 
   milestone AS __group__,
   t.id AS ticket,
   summary,
   reporter as prioritizer,
   component, version, status, t.priority, severity, milestone,
   t.type AS type, 
   t.time AS created,
   changetime AS _changetime, 
   description AS _description,
   reporter AS _reporter
  FROM ticket t
  WHERE priority <> 'average' 
   AND reporter not IN ('admin','other_admin')
   AND status <> 'closed'
   AND t.id NOT IN (
       SELECT ticket FROM ticket_change WHERE field='priority' 
   )
UNION
-- with all changes made by others:
 SELECT 
   milestone AS __group__,
   t.id AS ticket, 
   summary,
   c.author as prioritizer, 
   component, version, status, t.priority, severity, milestone,
   t.type AS type, 
   t.time AS created,
   changetime AS _changetime, 
   description AS _description,
   reporter AS _reporter
  FROM ticket_change c, ticket t
  WHERE t.id=c.ticket and field='priority' 
   AND author not IN ('admin','other_admin')
   AND status <> 'closed'
ORDER BY milestone, author, prioritizer

But that has a lot of tickets, that are corrected by Admin already by now.


How can I select only those tickets, where the last prioritization (or initial if the only one) is not made by Admin himself?

I made that a sepyrate Question here:

https://stackoverflow.com/questions/17647694/trac-report-that-shows-the-author-of-the-last-prioritization-change

Was it helpful?

Solution

Yes, it's possible to distinguish that with an individual Trac query.

This is how you create such special query (with permissions to create queries). Unfortunately, it's too special to create such query with the GUI elements on page "Individual Query". These are the steps:

  1. Select "View Tickets" from the main menu
  2. click the "Create New Report" button, you'll get to the edit page then
  3. Set a title like "All tickets modified (but not by Admin)"
  4. Put this SQL query in the "Query for report" edit field:

    SELECT id,reporter FROM ticket WHERE priority <> 'average' AND reporter not IN (SELECT username FROM permission WHERE action='TRAC_ADMIN')

    or this one to see ticket changes made by users who aren't admins:

    SELECT ticket,author FROM ticket_change WHERE field='priority' and author not IN (SELECT username FROM permission WHERE action='TRAC_ADMIN')

  5. Save the report and it'll get a new report number

  6. Click that report on the report page (go to there with a click on main menu item "View Tickets"), and there you go!

The inner SELECT gets all admins from the permission database table, the outer SELECT finds all tickets created/changed by people not being one of the admins. Database table ticket_change also has a column 'time' you can use to extend your SQL query for adding a condition like "only changes of the latest n days" or something like that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top