[Rt-commit] [rtir] 01/01: Make RTIR_OldestRelatedTickets apply to IP searches as well

Kevin Falcone falcone at bestpractical.com
Fri Jul 25 18:37:10 EDT 2014


This is an automated email from the git hooks/post-receive script.

falcone pushed a commit to branch 3.2/oldestrelatedtickets
in repository rtir.

commit a39a4e92f52d303a19e07a46ea2b5edbf3ca562f
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Fri Jul 25 18:29:17 2014 -0400

    Make RTIR_OldestRelatedTickets apply to IP searches as well
    
    Back in RTIR 1, we did a FTS search (slowly) for IP addresses or
    hostnames, so it made sense to limit which transactions we searched
    (especially as there was no optimized FTS available).
    
    In recent years, this was changed to only apply to the FTS for
    hostnames, but most people are searching on IPs and find older tickets
    they don't want.
    
    Now that we have native FTS available, we should just do a CF search OR
    a Content LIKE search and then limit for tickets LastUpdated.  This
    isn't quite the same as before (which would attempt to only search
    Transactions added after RTIR_OldestRelatedTickets) but since any FTS is
    going to go against the index anyway, we should just make it do more
    like what people want.
    
    Fixes issues #14427
---
 etc/RTIR_Config.pm                            |  9 +++++----
 html/RTIR/Tools/Elements/LookupRelatedTickets | 21 ++++++++-------------
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index 634a76b..f2f3424 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -312,10 +312,11 @@ Set($ReplyString , '');
 
 =item C<$RTIR_OldestRelatedTickets>
 
-Controls how far back, in days, RTIR should look for tickets which might
-contain a specific string. This is only used for Content searches,
-searches based on IP or other Custom Fields are not limited by age
-because the current implementation has poor performance.
+Controls what tickets (LastUpdated > "RTIR_OldestRelatedTickets days ago")
+are returned for searches generated from the Lookup tools. This applies
+to searches for IP addresses and Hostnames linked from Ticket histories
+that are run against Lookup.html and any other custom code that links to
+Lookup.html to run a query.
 
 =cut
 
diff --git a/html/RTIR/Tools/Elements/LookupRelatedTickets b/html/RTIR/Tools/Elements/LookupRelatedTickets
index 54c83f6..fef8015 100644
--- a/html/RTIR/Tools/Elements/LookupRelatedTickets
+++ b/html/RTIR/Tools/Elements/LookupRelatedTickets
@@ -77,18 +77,13 @@ return unless defined $q && length $q;
 
 my $query;
 if ( $LookupType && RT::IR->CustomFields( Field => $LookupType ) ) {
-    $query = "'CF.{$LookupType}' = '$q'"
-} else {
-    $query = join ' OR ', map "ContentType = '$_'",
-        qw(text/plain text/html text);
-    $query = "( $query ) AND Content LIKE '$q'";
-
-    # apply transaction date search only if it's FTS as otherwise
-    # it can ruin performance of mysql optimizer rather than help
-    my $age = RT::Date->new( $session{'CurrentUser'} );
-    $age->SetToNow;
-    $age->AddDays( 0 - (RT->Config->Get('RTIR_OldestRelatedTickets') || 60) );
-
-    $query = "$query AND TransactionDate > '". $age->ISO ."'"
+    $query = "'CF.{$LookupType}' = '$q' "
+} else { # generally FTS on hostnames from MakeClicky
+    unless (RT->Config->Get('FullTextSearch')->{Enable}) {
+        RT->Logger->error("Asked to run a full text search from Lookup.html without full text search enabled, see %FullTextSearch in RT_Config.pm");
+    }
+    $query = "Content LIKE '$q'";
 }
+my $age = RT->Config->Get('RTIR_OldestRelatedTickets') || 60;
+$query = "$query AND LastUpdated > '$age days ago'";
 </%init>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list