Index: trunk/ippTools/share/disttool_pending_camera.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_camera.sql	(revision 30272)
+++ trunk/ippTools/share/disttool_pending_camera.sql	(revision 30387)
@@ -15,5 +15,6 @@
     camProcessedExp.quality,
     distRun.no_magic,
-    chipRun.magicked
+    chipRun.magicked,
+    IFNULL(Label.priority, 10000) AS priority
 FROM distRun
 JOIN distTarget USING(target_id, stage, clean)
@@ -21,9 +22,9 @@
 JOIN camProcessedExp USING(cam_id)
 JOIN chipRun USING(chip_id)
--- JOIN chipProcessedImfile USING(exp_id, chip_id)
 JOIN rawExp using(exp_id)
 LEFT JOIN distComponent 
     ON distRun.dist_id = distComponent.dist_id 
---    AND chipProcessedImfile.class_id = distComponent.component
+LEFT JOIN Label
+    ON distRun.label = Label.label
 WHERE
     distRun.state = 'new'
@@ -32,2 +33,3 @@
     AND (((clean OR (chipRun.magicked != 0)) AND (camRun.magicked > 0)) OR distRun.no_magic)
     AND (camRun.state = 'full' OR (distRun.clean AND camRun.state = 'cleaned'))
+    AND (Label.active OR Label.active IS NULL)
