diff options
author | jayce <jayce> | 2007-09-28 00:33:16 +0000 |
---|---|---|
committer | jayce <jayce> | 2007-09-28 00:33:16 +0000 |
commit | 11f1a064f3618bac4078c8ae86654b3182ec0e07 (patch) | |
tree | 0437bf663313291f27bdef5dccd05faf6fe7a1f3 | |
parent | 34f8c7273c726b62f6a0031b7adf788bfb81e35e (diff) |
Fixes a bug where retry_realtime isn't limiting to that user's events, therefore selecting all retryable events, and having to filter later. On a system with a running history, this caused bad O() types of situations for performance, especially bad when this was called by something that a user would be awaiting feedback from
-rw-r--r-- | FS/FS/cust_main.pm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 9627f9f..a36273b 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2731,6 +2731,13 @@ sub retry_realtime { my $join = FS::part_event_condition->join_conditions_sql; my $order = FS::part_event_condition->order_conditions_sql; + my $mine = + '( ' + . join ( ' OR ' , map { + "( part_event.eventtable = " . dbh->quote($_) + . " AND tablenum IN( SELECT " . dbdef->table($_)->primary_key . " from $_ where custnum = " . dbh->quote( $self->custnum ) . "))" ; + } FS::part_event->eventtables) + . ') '; #here is the agent virtualization my $agent_virt = " ( part_event.agentnum IS NULL @@ -2754,7 +2761,7 @@ sub retry_realtime { 'addl_from' => "LEFT JOIN part_event USING ( eventpart ) $join", 'hashref' => { 'status' => 'done' }, 'extra_sql' => " AND statustext IS NOT NULL AND statustext != '' ". - " AND $is_realtime_event AND $agent_virt $order" # LIMIT 1" + " AND $mine AND $is_realtime_event AND $agent_virt $order" # LIMIT 1" }); my %seen_invnum = (); |