Index: openacs.org-dev/packages/ecommerce/tcl/ecommerce-scheduled-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs.org-dev/packages/ecommerce/tcl/ecommerce-scheduled-procs.tcl,v diff -u -r1.1.1.1 -r1.1.1.2 --- openacs.org-dev/packages/ecommerce/tcl/ecommerce-scheduled-procs.tcl 9 Jul 2002 17:35:05 -0000 1.1.1.1 +++ openacs.org-dev/packages/ecommerce/tcl/ecommerce-scheduled-procs.tcl 8 Oct 2002 15:47:06 -0000 1.1.1.2 @@ -54,18 +54,26 @@ } { - # For each product find other products that are items of orders - # with the same user_id. + # First prune expired combinations. A combination is deemed + # expired when one of the products is inactive. - db_foreach products_select "select product_id from ec_products" { + ec_prune_product_purchase_combinations + + # For each active product find other active products that are + # items of orders with the same user_id. + + db_foreach products_select "select product_id from ec_products where active_p = 't'" { + + # Then find current product combinations. + set correlated_product_counter 0 set insert_cols [list] set insert_vals [list] set update_items [list] db_foreach correlated_products_select " select i2.product_id as correlated_product_id, count(*) as n_product_occurrences - from ec_items i2 + from ec_items i2, ec_products p where i2.order_id in (select o2.order_id from ec_orders o2 where o2.user_id in (select user_id @@ -74,6 +82,8 @@ from ec_items i where product_id = :product_id))) and i2.product_id <> :product_id + and i2.product_id = p.product_id + and p.active_p = 't' group by i2.product_id order by n_product_occurrences desc" { if { $correlated_product_counter >= 5 } {