[Rt-commit] r6802 - in rtir/branches/2.2-TESTING: lib/RT/Action
ruz at bestpractical.com
ruz at bestpractical.com
Tue Jan 23 19:12:52 EST 2007
Author: ruz
Date: Tue Jan 23 19:12:50 2007
New Revision: 6802
Modified:
rtir/branches/2.2-TESTING/ (props changed)
rtir/branches/2.2-TESTING/lib/RT/Action/RTIR_SetConstituency.pm
Log:
r1856 at cubic-pc (orig r6792): ruz | 2007-01-22 23:58:33 +0300
r1854 at cubic-pc: cubic | 2007-01-23 00:09:40 +0300
* split query into two by OR to improve mysql's plan
Modified: rtir/branches/2.2-TESTING/lib/RT/Action/RTIR_SetConstituency.pm
==============================================================================
--- rtir/branches/2.2-TESTING/lib/RT/Action/RTIR_SetConstituency.pm (original)
+++ rtir/branches/2.2-TESTING/lib/RT/Action/RTIR_SetConstituency.pm Tue Jan 23 19:12:50 2007
@@ -37,8 +37,7 @@
." OR Queue = 'Incident Reports'"
." OR Queue = 'Investigations'"
." OR Queue = 'Blocks'"
- .")"
- ." AND ( MemberOf = ". $ticket->Id ." OR HasMember = ". $ticket->Id ." )";
+ .")";
if ( $constituency ) {
$query .= " AND CF.{_RTIR_Constituency} != '$constituency'";
@@ -46,15 +45,18 @@
$query .= " AND CF.{_RTIR_Constituency} IS NOT NULL";
}
- my $tickets = RT::Tickets->new( $RT::SystemUser );
- $tickets->FromSQL( $query );
- while ( my $t = $tickets->Next ) {
- $RT::Logger->debug( "Ticket #". $t->id ." inherits constituency from ticket #". $ticket->id );
- my ($res, $msg) = $t->AddCustomFieldValue(
- Field => '_RTIR_Constituency',
- Value => $constituency,
- );
- $RT::Logger->warning( "Couldn't set CF: $msg" ) unless $res;
+ # do two queries as mysql couldn't optimize things well
+ foreach my $link_type (qw(MemberOf HasMember)) {
+ my $tickets = RT::Tickets->new( $RT::SystemUser );
+ $tickets->FromSQL( $query ." AND $link_type = ". $ticket->Id );
+ while ( my $t = $tickets->Next ) {
+ $RT::Logger->debug( "Ticket #". $t->id ." inherits constituency from ticket #". $ticket->id );
+ my ($res, $msg) = $t->AddCustomFieldValue(
+ Field => '_RTIR_Constituency',
+ Value => $constituency,
+ );
+ $RT::Logger->warning( "Couldn't set CF: $msg" ) unless $res;
+ }
}
return 1;
}
More information about the Rt-commit
mailing list