Index: trunk/ippTools/share/laptool_definerun.sql
===================================================================
--- trunk/ippTools/share/laptool_definerun.sql	(revision 31604)
+++ trunk/ippTools/share/laptool_definerun.sql	(revision 32422)
@@ -1,3 +1,8 @@
-SELECT DISTINCT want.exp_id, have.chip_id, false as private, true as active, false as pairwise
+SELECT DISTINCT 
+  want.exp_id, 
+  have.chip_id, 
+  COALESCE(have.private,false) as private, 
+  true as active, 
+  false as pairwise
   FROM
   (SELECT exp_id FROM rawExp 
@@ -8,15 +13,21 @@
   ) AS want
   LEFT JOIN 
-  (SELECT exp_id,MAX(chip_id) AS chip_id, chipRun.state
+  (SELECT 
+     exp_id,
+     MAX(chip_id) AS chip_id, 
+     chipRun.state,
+     lapExp.private
      FROM lapExp JOIN chipRun USING(exp_id,chip_id) 
-     where private IS FALSE 
-     AND chip_id IS NOT NULL
+     JOIN lapRun USING(lap_id)
+     where chip_id IS NOT NULL
      AND 
-     	 (
+-- This is the restriction to only draw from the current lapSequence
+     @CHIPWHERE@
+--     	 (
 	  -- (active = TRUE) OR 
-	  (chipRun.state = 'full') OR
-	  (chipRun.state = 'new')
+	  -- (chipRun.state = 'full') OR
+	  -- (chipRun.state = 'new')
 	  -- when we can do updates, put that here.
-	  )
+--	  )
      GROUP BY exp_id
 ) AS have USING(exp_id)
