[rt-users] Searching on status of depedencies?

Todd L Miller tlmiller at cs.wisc.edu
Thu Sep 11 18:30:56 EDT 2008


> It looks like the cleanest way to do this would be to write a custom 
> search that calls $Ticket->HasUnresolvedDependencies() for each item in 
> the collection's results.

 	For other people who may come googling by, "custom search" appears 
to mean writing a Perl module in lib/RT/Search; I started by copying 
Googleish.pm, since it was simpler.  You can test the search from the 
command-line (sometimes, depending on your database it set up) using 
rt-crontool's --search option (RT::Search::MyNewSearch).  (Setting 
--command and --condition to the "Generic" modules seems to work for 
no-ops, since, IIRC, rt-crontool will be unhappy without them.  Note that 
you'll have to print the results in your search code to actually see 
them.)  You can test the search in the web interface by copying 
Simple.html and changing the names appropriately.  Note that /both/ Mason 
and mod_perl do caching, so changing your custom search after you've used 
it from the web may require restarting the web server (as well as clearing 
Mason's cache).

 	The advantage of this approach is that it's minimally invasive; 
only one page, not linked to from anywhere, calls the custom search you 
wrote.  I don't believe that 'saved search', however, saves the search 
module used to generate the results.  (Certainly, I didn't see anyway to 
specify that in the web UI, which was disappointing.)  It would have been 
cool, because I generally like the idea of the 'RT at a glance' page, and 
would like to have had my custom search show up in it.  My guess is that 
the simplest way to do this is to customize the usual search 
(RT/Search/FromSQL?) to recognized some magic constant in the input 
TicketSQL and switch to the custom search when if finds it.  (e.g. 
"CustomSearch = 'True'").

 	In fact, it would be mighty cool if that became a part of RT's 
TicketSQL: "AND CustomSearch = 'RT::Search::MyCustomSearch'".

- Todd Miller

 	One implementation note: $self->TicketsObj->ItemsArrayRef() caches 
its results.  Calling delete( $self->TicketsObj->{ 'items_array' } ) seems 
to be how to clear the cache, which was useful for debugging, and may be 
necessary (to get correct results); I don't really understand the 
implementation.



More information about the rt-users mailing list