X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-torrus-srvderive;h=525d6ceb5194c30d62580671f6ceecca505e93bb;hb=144668a01beef406a027c78bc2883e111e621cc2;hp=a02d23ea05cb4c2fd9462484f968a85b57f23d3c;hpb=89cd0ae97ac521827060f147528d3c99de24b38a;p=freeside.git diff --git a/FS/bin/freeside-torrus-srvderive b/FS/bin/freeside-torrus-srvderive index a02d23ea0..525d6ceb5 100644 --- a/FS/bin/freeside-torrus-srvderive +++ b/FS/bin/freeside-torrus-srvderive @@ -60,8 +60,13 @@ my $sql = " my $orderlimit = " ORDER BY srv_date, srv_time - LIMIT 100 -"; #50? + LIMIT 50 +"; + +if ( driver_name eq 'mysql' ) { + dbh->do('SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); + dbh->commit or die dbh->errstr; +} our $kids = 0; @@ -190,9 +195,12 @@ while (1) { my $sin = join(',', map dbh->quote("$_$dir"), @serviceids); + my $srv_date = time2str('%Y-%m-%d', $cur); + my $sum = " SELECT COALESCE(SUM(value),0) FROM srvexport AS other WHERE other.serviceid IN ($sin) + AND other.srv_date = '$srv_date' AND ABS( $cur - $other_date ) <= 60 "; @@ -200,10 +208,10 @@ while (1) { INSERT INTO srvexport ( srv_date, srv_time, serviceid, value, intvl ) VALUES ( ?, ?, ?, ($sum), ? ) "; - my @param = ( time2str('%Y-%m-%d', $cur), #srv_date - time2str('%X', $cur), #srv_time - "$serviceid$dir", - 300, #intvl ... + my @param = ( $srv_date, + time2str('%X', $cur), #srv_time + "$serviceid$dir", #serviceid + 300, #intvl ... ); warn $isql. ' with param '. join(',',@param). "\n" if $DEBUG > 2;