[freeside-commits] branch master updated. 0576052155894acbda02aac05e136ed030b5707f

Ivan ivan at 420.am
Sat May 3 14:01:38 PDT 2014


The branch, master has been updated
       via  0576052155894acbda02aac05e136ed030b5707f (commit)
       via  05a570db47faf7d497663fa52914d1cb4750174a (commit)
      from  aa5243865fe7d13da661728f7e820d1f86c8a7f5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0576052155894acbda02aac05e136ed030b5707f
Merge: 05a570d aa52438
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat May 3 14:01:34 2014 -0700

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit 05a570db47faf7d497663fa52914d1cb4750174a
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat May 3 14:01:26 2014 -0700

    optimize event queries, RT#28978, possible MySQL band-aid, RT#28978

diff --git a/FS/FS/part_event_condition.pm b/FS/FS/part_event_condition.pm
index 78aa3b1..b51c6b9 100644
--- a/FS/FS/part_event_condition.pm
+++ b/FS/FS/part_event_condition.pm
@@ -253,7 +253,6 @@ B<where_conditions_sql>.
 
 sub join_conditions_sql {
   my ( $class, $eventtable ) = @_;
-  my %conditions = $class->conditions( $eventtable );
 
   join(' ',
     map {
@@ -262,7 +261,8 @@ sub join_conditions_sql {
           "       AND cond_$_.conditionname = ". dbh->quote($_).
           "     )";
         }
-        keys %conditions
+      map $_->[0], $class->_where_conditions( $eventtable ) #, %options )
+
   );
 
 }
@@ -280,27 +280,38 @@ as passed to freeside-daily), as a UNIX timestamp.
 sub where_conditions_sql {
   my ( $class, $eventtable, %options ) = @_;
 
+  join(' AND ',
+         map { my $conditionname = $_->[0];
+               my $sql = $_->[1];
+               "( cond_$conditionname.conditionname IS NULL OR $sql )";
+             }
+           $class->_where_conditions( $eventtable, %options )
+      );
+}
+
+sub _where_conditions {
+  my ( $class, $eventtable, %options ) = @_;
+
   my $time = $options{'time'};
 
   my %conditions = $class->conditions( $eventtable );
 
-  my $where = join(' AND ',
+  grep { $_->[1] !~ /^\s*true\s*$/i
+         || $conditions{ $_->[0] }->{order_sql}
+       }
     map {
           my $conditionname = $_;
           my $coderef = $conditions{$conditionname}->{condition_sql};
+          #die "$coderef is not a CODEREF" unless ref($coderef) eq 'CODE';
           my $sql = &$coderef( $eventtable, 'time'        => $time,
                                             'driver_name' => driver_name(),
                              );
-          die "$coderef is not a CODEREF" unless ref($coderef) eq 'CODE';
-          "( cond_$conditionname.conditionname IS NULL OR $sql )";
+          [ $_, $sql ];
         }
-        grep { my $cond = $_;
-               ! grep { $_ eq $cond } @SKIP_CONDITION_SQL
-             }
-             keys %conditions
-  );
-
-  $where;
+      grep { my $cond = $_;
+             ! grep { $_ eq $cond } @SKIP_CONDITION_SQL
+           }
+        keys %conditions;
 }
 
 =item order_conditions_sql [ EVENTTABLE ]

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_event_condition.pm |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list