Merge tix with matching CFs


I found a post from a ways back asking how to do this, with a
nonfunctional scrip code. The OP wants to do what i want to do:

“What I am trying to do now, is on each ticket submission, Extract
that [Custom] field
and then check to see if there is another ticket that has that same number
in the custom field and if they match, merge the tickets.”

My first question is, assuming a reasonably tuned MySQL suitable to
its (fast) hardware: how horrible would this be in an ever-growing DB?
It must search the DB for every last ticket and compare the two CFs,

The posted code was:
my $TicketsObj = RT::Tickets->new($RT::SystemUser);
$TicketsObj->LimitQueue(VALUE => ‘AfterHoursSupport’);
$TicketsObj->LimitCustomField(CUSTOMFIELD => ‘AfterHoursTicketNumber’,
OPERATOR => ‘=’, VALUE => $AHTixNum);

if ($TicketsObj->Count == 0) { return 1; }
my $id = undef;
while (my $ticket = $TicketsObj->Next) {
next if $self->TicketObj->Id == $ticket->Id;
$id = $ticket->Id;

$id || return 1;

$RT::Logger->debug(“Merging ticket " . $self->TicketObj->Id . " into $id
because of OA number match.”);


The OP did not specify exactly which chunks went where, but that he’d
tried various combinations of condition and prep.
My first thought was that this was incorrect; the condition is
OnCreate and no code need go in that block. Prep should be the field
search and compare, and cleanup the ticket merge itself, yes?

(the above is the OP’s exact code and doesn’t reflect my own setup).

/chown -R us:us /yourbase