[freeside-commits] branch FREESIDE_3_BRANCH updated. 1dc0b3496b1eff80b424a3f4a34d7006eb8844a5
Mark Wells
mark at 420.am
Wed Sep 4 15:00:10 PDT 2013
The branch, FREESIDE_3_BRANCH has been updated
via 1dc0b3496b1eff80b424a3f4a34d7006eb8844a5 (commit)
from 0f9ba3cb4bccfe3bcd2b085698f88938cd94bdf4 (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 1dc0b3496b1eff80b424a3f4a34d7006eb8844a5
Author: Mark Wells <mark at freeside.biz>
Date: Wed Sep 4 15:00:05 2013 -0700
optimize prepaid balance query, #24846
diff --git a/FS/FS/ClientAPI/PrepaidPhone.pm b/FS/FS/ClientAPI/PrepaidPhone.pm
index b05fb4f..2cea3c2 100644
--- a/FS/FS/ClientAPI/PrepaidPhone.pm
+++ b/FS/FS/ClientAPI/PrepaidPhone.pm
@@ -307,14 +307,8 @@ sub prepaid_phone_balance {
foreach my $cust_svc ( @cust_svc ) {
my $svc_x = $cust_svc->svc_x;
-
- #XXX optimization: a single SQL query to return the total amount
- my $cdr_search = $svc_x->psearch_cdrs(%options);
- $cdr_search->limit(1000);
- $cdr_search->increment(0);
- while ( my $cdr = $cdr_search->fetch ) {
- $balance -= $cdr->rated_price;
- }
+ my $sum_cdr = $svc_x->sum_cdrs(%options);
+ $balance += $sum_cdr->rated_price;
}
-----------------------------------------------------------------------
Summary of changes:
FS/FS/ClientAPI/PrepaidPhone.pm | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
More information about the freeside-commits
mailing list