projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0f9ba3c
)
optimize prepaid balance query, #24846
author
Mark Wells
<mark@freeside.biz>
Wed, 4 Sep 2013 22:00:05 +0000
(15:00 -0700)
committer
Mark Wells
<mark@freeside.biz>
Wed, 4 Sep 2013 22:00:05 +0000
(15:00 -0700)
FS/FS/ClientAPI/PrepaidPhone.pm
patch
|
blob
|
history
diff --git
a/FS/FS/ClientAPI/PrepaidPhone.pm
b/FS/FS/ClientAPI/PrepaidPhone.pm
index
b05fb4f
..
2cea3c2
100644
(file)
--- 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;
}