Index: trunk/ippTools/share/disttool_toadvance.sql
===================================================================
--- trunk/ippTools/share/disttool_toadvance.sql	(revision 28730)
+++ trunk/ippTools/share/disttool_toadvance.sql	(revision 28733)
@@ -74,4 +74,28 @@
     HAVING
         COUNT(chipProcessedImfile.class_id) = COUNT(distComponent.component)
+        AND SUM(distComponent.fault) = 0
+UNION
+-- chip_bg stage
+SELECT
+    distRun.dist_id,
+    stage,
+    stage_id,
+    outroot,
+    label,
+    clean
+    FROM distRun
+    JOIN chipBackgroundImfile ON stage_id = chipBackgroundImfile.chip_bg_id
+    LEFT JOIN distComponent
+        ON distComponent.dist_id = distRun.dist_id
+        AND distComponent.component = chipBackgroundImfile.class_id
+    WHERE
+        distRun.state = 'new'
+        AND distRun.fault = 0
+        AND distRun.stage = 'chip_bg'
+    GROUP BY
+        dist_id,
+        chipBackgroundImfile.chip_bg_id
+    HAVING
+        COUNT(chipBackgroundImfile.class_id) = COUNT(distComponent.component)
         AND SUM(distComponent.fault) = 0
 UNION
@@ -145,4 +169,30 @@
         AND SUM(distComponent.fault) = 0
 UNION
+-- warp_bg stage
+SELECT
+    distRun.dist_id,
+    stage,
+    stage_id,
+    outroot,
+    label,
+    clean
+    FROM distRun
+    JOIN warpBackgroundSkyfile on stage_id = warp_bg_id
+    LEFT JOIN distComponent
+        ON distRun.dist_id = distComponent.dist_id
+        AND distComponent.component = warpBackgroundSkyfile.skycell_id
+    WHERE
+        distRun.state = 'new'
+        AND distRun.fault = 0
+        AND distRun.stage = 'warp_bg'
+--        AND warpSkyfile.fault = 0
+--        AND warpSkyfile.quality = 0
+    GROUP BY
+        distRun.dist_id,
+        warp_bg_id
+    HAVING
+        COUNT(warpBackgroundSkyfile.skycell_id) = COUNT(distComponent.component)
+        AND SUM(distComponent.fault) = 0
+UNION
 -- diff stage
 SELECT
