? .bzr ? 435084_200904161504+1000.patch ? 435088_200904161515+1000.patch ? 437268_200904182100+1000.patch ? 437928_200904190938+1000.patch ? 465536_200907031741-0400.patch ? 471834_200905251156+1000.patch ? 471922_200905251440+1000.patch ? 477102_200906011301+1000.patch ? 500884_wrap_option_names.patch ? bzr_changelog ? customer-products_reports.patch ? customer-products_reports_fixed.patch ? tmp_ubercart.patch ? uc_reports/views Index: uc_order/uc_order.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_order/uc_order.install,v retrieving revision 1.9.2.12 diff -u -r1.9.2.12 uc_order.install --- uc_order/uc_order.install 6 May 2009 18:38:02 -0000 1.9.2.12 +++ uc_order/uc_order.install 3 Jul 2009 21:41:51 -0000 @@ -502,6 +502,8 @@ ), 'indexes' => array( 'order_id' => array('order_id'), + 'nid' => array('nid'), + 'qty' => array('qty'), ), 'primary key' => array('order_product_id'), ); @@ -987,3 +989,15 @@ return $ret; } + +/** + * Add an index so that product and customer reports are usable with large datasets + */ +function uc_order_update_6011() { + $ret = array(); + + db_add_index($ret, 'uc_order_products', 'nid', array('nid')); + db_add_index($ret, 'uc_order_products', 'qty', array('qty')); + + return $ret; +} Index: uc_reports/uc_reports.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_reports/Attic/uc_reports.admin.inc,v retrieving revision 1.1.2.8 diff -u -r1.1.2.8 uc_reports.admin.inc --- uc_reports/uc_reports.admin.inc 18 Apr 2009 07:29:17 -0000 1.1.2.8 +++ uc_reports/uc_reports.admin.inc 3 Jul 2009 21:41:55 -0000 @@ -47,7 +47,7 @@ $header = array( array('data' => t('#')), - array('data' => t('Customer'), 'field' => "ou.$last_name"), + array('data' => t('Customer'), 'field' => "o.$last_name"), array('data' => t('Username'), 'field' => "u.name"), array('data' => t('Orders'), 'field' => 'orders'), array('data' => t('Products'), 'field' => 'products'), @@ -56,20 +56,8 @@ ); $csv_rows[] = array(t('#'), t('Customer'), t('Username'), t('Orders'), t('Products'), t('Total'), t('Average')); - $sql = ''; - $sql_count = ''; - - switch ($GLOBALS['db_type']) { - case 'mysqli': - case 'mysql': - $sql = "SELECT u.uid, u.name, ou.$first_name, ou.$last_name, (SELECT COUNT(DISTINCT(order_id)) FROM {uc_orders} as o WHERE o.uid = u.uid AND o.order_status IN $order_statuses) as orders, (SELECT SUM(qty) FROM {uc_order_products} as ps LEFT JOIN {uc_orders} as os ON ps.order_id = os.order_id WHERE os.order_status IN $order_statuses AND os.uid = u.uid) as products, (SELECT SUM(ot.order_total) FROM {uc_orders} as ot WHERE ot.uid = u.uid AND ot.order_status IN $order_statuses) as total, ROUND((SELECT SUM(ot.order_total) FROM {uc_orders} as ot WHERE ot.uid = u.uid AND ot.order_status IN $order_statuses)/(SELECT COUNT(DISTINCT(order_id)) FROM {uc_orders} as o WHERE o.uid = u.uid AND o.order_status IN $order_statuses), 2) as average FROM {users} as u LEFT JOIN {uc_orders} as ou ON u.uid = ou.uid WHERE u.uid > 0 GROUP BY u.uid"; - $sql_count = "SELECT COUNT(DISTINCT(u.uid)) FROM {users} as u LEFT JOIN {uc_orders} as ou ON u.uid = ou.uid WHERE u.uid > 0"; - break; - case 'pgsql': - $sql = "SELECT u.uid, u.name, ou.$first_name, ou.$last_name, (SELECT COUNT(DISTINCT(order_id)) FROM {uc_orders} as o WHERE o.uid = u.uid AND o.order_status IN $order_statuses) as orders, (SELECT SUM(qty) FROM {uc_order_products} as ps LEFT JOIN {uc_orders} as os ON ps.order_id = os.order_id WHERE os.order_status IN $order_statuses AND os.uid = u.uid) as products, (SELECT SUM(ot.order_total) FROM {uc_orders} as ot WHERE ot.uid = u.uid AND ot.order_status IN $order_statuses) as total, ROUND((SELECT SUM(ot.order_total) FROM {uc_orders} as ot WHERE ot.uid = u.uid AND ot.order_status IN $order_statuses)/(SELECT COUNT(DISTINCT(order_id)) FROM {uc_orders} as o WHERE o.uid = u.uid AND o.order_status IN $order_statuses), 2) as average FROM {users} as u LEFT JOIN {uc_orders} as ou ON u.uid = ou.uid WHERE u.uid > 0 GROUP BY u.uid, u.name, ou.$first_name, ou.$last_name"; - $sql_count = "SELECT COUNT(DISTINCT(u.uid)) FROM {users} as u LEFT JOIN {uc_orders} as ou ON u.uid = ou.uid WHERE u.uid > 0"; - break; - } + $sql = "SELECT u.uid, u.name, o.$first_name, o.$last_name, COUNT(DISTINCT o.order_id) AS orders, SUM(op.qty) AS products, SUM(o.order_total) AS total, AVG(o.order_total) AS average FROM {uc_orders} AS o LEFT JOIN {users} AS u ON o.uid = u.uid JOIN (SELECT order_id, SUM(qty) AS qty FROM {uc_order_products} GROUP BY order_id) AS op ON o.order_id = op.order_id WHERE o.order_status IN $order_statuses GROUP BY u.uid, u.name, o.$first_name, o.$last_name"; + $sql_count = "SELECT COUNT(u.uid) FROM {uc_orders} AS o LEFT JOIN {users} AS u ON o.uid = u.uid JOIN (SELECT order_id, SUM(qty) AS qty FROM {uc_order_products} GROUP BY order_id) AS op ON o.order_id = op.order_id WHERE o.order_status IN $order_statuses"; $context = array( 'revision' => 'formatted-original',