Index: trunk/ippTools/share/disttool_pending_stack.sql
===================================================================
--- trunk/ippTools/share/disttool_pending_stack.sql	(revision 25838)
+++ trunk/ippTools/share/disttool_pending_stack.sql	(revision 30387)
@@ -17,5 +17,6 @@
     stackSumSkyfile.quality,
     1 AS no_magic,
-    0 AS magicked
+    0 AS magicked,
+    IFNULL(Label.priority, 10000) AS priority
 FROM distRun
 JOIN distTarget USING(target_id, stage, clean)
@@ -43,4 +44,5 @@
     ON distRun.dist_id = distComponent.dist_id 
     AND stackRun.skycell_id = distComponent.component
+LEFT JOIN Label ON distRun.label = Label.label
 WHERE
     distRun.state = 'new'
@@ -49,2 +51,3 @@
     AND (stackRun.state = 'full' OR (distRun.clean AND stackRun.state = 'cleaned'))
     AND (stackSumSkyfile.fault = 0 AND stackSumSkyfile.quality = 0)
+    AND (Label.active OR Label.active IS NULL)
