Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r9677: LJSV-1228 (Shop history page fails to lo...

Committer: ailyin
LJSV-1228 (Shop history page fails to load for people with large numbers of orders)
U   trunk/cgi-bin/LJ/Pay/Payment.pm
U   trunk/cgi-bin/LJ/Widget/Shop/History.pm
Modified: trunk/cgi-bin/LJ/Pay/Payment.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment.pm	2010-11-08 09:51:23 UTC (rev 9676)
+++ trunk/cgi-bin/LJ/Pay/Payment.pm	2010-11-08 11:49:00 UTC (rev 9677)
@@ -2043,20 +2043,29 @@
     $userid = LJ::want_userid($userid);
 
     my $dbh = LJ::get_db_writer();
-    my $payids = $dbh->selectcol_arrayref(qq{
-        SELECT payid FROM payments
+    my $res = $dbh->selectall_arrayref(qq{
+        SELECT * FROM payments
         WHERE userid=? AND (forwhat="cart" OR forwhat="recbill")
         ORDER BY payid DESC
-    }, undef, $userid);
+    }, { 'Slice' => {} }, $userid);
 
     my @ret;
-    foreach my $payid (@$payids) {
-        my $cart = eval { $class->load('payid' => $payid) };
+    if (@$res > 50) {
+        # less resource-consuming way: show all carts
+        foreach my $row (@$res) {
+            push @ret, $class->new_memonly(%$row);
+        }
+    } else {
+        # we can go ahead and load items, so that we can hide
+        # empty carts, nifty!
+        foreach my $row (@$res) {
+            my $cart = eval { $class->load('payid' => $row->{'payid'}) };
 
-        next unless $cart;
-        next unless $cart->get_items;
+            next unless $cart;
+            next unless $cart->get_items;
 
-        push @ret, $cart;
+            push @ret, $cart;
+        }
     }
 
     return \@ret;

Modified: trunk/cgi-bin/LJ/Widget/Shop/History.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/History.pm	2010-11-08 09:51:23 UTC (rev 9676)
+++ trunk/cgi-bin/LJ/Widget/Shop/History.pm	2010-11-08 11:49:00 UTC (rev 9677)
@@ -114,7 +114,6 @@
                 $des = LJ::Lang::ml('wallet.widget.history.des.order', {
                     'cart_link' => $cart_link,
                 });
-                warn $des;
             }
         }
 

Tags: andy, ljcom, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments