Index: trunk/ippTools/share/disttool_pending_raw.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_raw.sql	(revision 27457)
+++ trunk/ippTools/share/disttool_pending_raw.sql	(revision 30387)
@@ -17,5 +17,6 @@
     0 as quality,
     distRun.no_magic,
-    rawImfile.magicked
+    rawImfile.magicked,
+    IFNULL(Label.priority, 10000) AS priority
 FROM distRun
 JOIN distTarget USING(target_id, stage, clean)
@@ -28,4 +29,5 @@
     ON distRun.dist_id = distComponent.dist_id 
     AND rawImfile.class_id = distComponent.component
+LEFT JOIN Label ON distRun.label = Label.label
 WHERE
     distRun.state = 'new'
@@ -34,4 +36,5 @@
     AND distComponent.dist_id IS NULL
     AND (rawExp.magicked OR distRun.no_magic)
+    AND (Label.active OR Label.active IS NULL)
 UNION
     -- raw stage alternate inputs
@@ -54,5 +57,6 @@
     0 as quality,
     distRun.no_magic,
-    rawImfile.magicked
+    rawImfile.magicked,
+    IFNULL(Label.priority, 10000) AS priority
 FROM distRun
 JOIN distTarget USING(target_id, stage, clean)
@@ -68,4 +72,5 @@
     ON distRun.dist_id = distComponent.dist_id 
     AND rawImfile.class_id = distComponent.component
+LEFT JOIN Label ON distRun.label = Label.label
 WHERE
     distRun.state = 'new'
@@ -74,4 +79,5 @@
     AND chipProcessedImfile.data_state = 'full'
     AND chipProcessedImfile.magicked > 0
+    AND (Label.active OR Label.active IS NULL)
 UNION
     -- raw stage clean (dbinfo only)
@@ -93,5 +99,6 @@
     0 as quality,
     distRun.no_magic,
-    rawExp.magicked
+    rawExp.magicked,
+    IFNULL(Label.priority, 10000) AS priority
 FROM distRun
 JOIN distTarget USING(target_id, stage, clean)
@@ -99,4 +106,5 @@
 LEFT JOIN distComponent 
     ON distRun.dist_id = distComponent.dist_id 
+LEFT JOIN Label ON distRun.label = Label.label
 WHERE
     distRun.state = 'new'
@@ -104,2 +112,3 @@
     AND distRun.clean
     AND distComponent.dist_id IS NULL
+    AND (Label.active OR Label.active IS NULL)
