Index: /branches/pap_mops/ippTools/share/pubtool_pending.sql
===================================================================
--- /branches/pap_mops/ippTools/share/pubtool_pending.sql	(revision 24450)
+++ /branches/pap_mops/ippTools/share/pubtool_pending.sql	(revision 24451)
@@ -2,14 +2,24 @@
     publishToDo.*
 FROM (
-    SELECT
+    -- Get the diffs
+    -- The following is only appropriate for a diff where warp1 is set; otherwise it's more difficult to get the camera name
+    SELECT DISTINCT
         publishRun.pub_id,
         publishClient.product,
         publishClient.stage,
         publishClient.workdir,
-        diffRun.diff_id AS stage_id
+        diffRun.diff_id AS stage_id,
+        rawExp.camera
     FROM publishRun
     JOIN publishClient USING(client_id)
     JOIN diffRun
         ON diffRun.diff_id = publishRun.stage_id
+    JOIN diffInputSkyfile USING(diff_id)
+    -- Need to do something fancy here to get the camera name for a stack
+    LEFT JOIN warpRun ON warpRun.warp_id = diffInputSkyfile.warp1
+    JOIN fakeRun USING(fake_id)
+    JOIN camRun USING(cam_id)
+    JOIN chipRun USING(chip_id)
+    JOIN rawExp USING(exp_id)
     WHERE publishClient.stage = 'diff'
         AND publishRun.state = 'new'
@@ -22,9 +32,12 @@
         publishClient.stage,
         publishClient.workdir,
-        camRun.cam_id AS stage_id
+        camRun.cam_id AS stage_id,
+        rawExp.camera
     FROM publishRun
     JOIN publishClient USING(client_id)
     JOIN camRun
         ON camRun.cam_id = publishRun.stage_id
+    JOIN chipRun USING(chip_id)
+    JOIN rawExp USING(exp_id)
     WHERE publishClient.stage = 'camera'
         AND publishRun.state ='new'
