Index: branches/eam_branches/ipp-20110505/ippTools/share/addtool_find_sky_id.sql
===================================================================
--- branches/eam_branches/ipp-20110505/ippTools/share/addtool_find_sky_id.sql	(revision 31587)
+++ branches/eam_branches/ipp-20110505/ippTools/share/addtool_find_sky_id.sql	(revision 31628)
@@ -3,6 +3,6 @@
 FROM 
      staticskyResult
-join staticSkyRun using (sky_id)
-join staticSkyInput using (stack_id)
+join staticskyRun using (sky_id)
+join staticskyInput using(sky_id)
 JOIN stackRun USING(stack_id)
 
@@ -13,5 +13,5 @@
           ) as foo
      ON sky_id = added_sky_id 
-     AND stage = 'sky'
+     AND stage = 'staticsky'
      -- hook for qualifying the join on the previous_dvodb
      AND %s
Index: branches/eam_branches/ipp-20110505/ippTools/share/addtool_find_sky_id_dvo.sql
===================================================================
--- branches/eam_branches/ipp-20110505/ippTools/share/addtool_find_sky_id_dvo.sql	(revision 31587)
+++ branches/eam_branches/ipp-20110505/ippTools/share/addtool_find_sky_id_dvo.sql	(revision 31628)
@@ -1,4 +1,7 @@
 SELECT staticskyRun.* FROM staticskyResult
 JOIN staticskyRun USING(sky_id)
+join staticskyInput using(sky_id)
+JOIN stackRun USING(stack_id)
+
 WHERE staticskyRun.state = 'full' and staticskyResult.quality = 0
     AND sky_id NOT IN (SELECT sky_id
Index: branches/eam_branches/ipp-20110505/ippTools/share/laptool_definerun.sql
===================================================================
--- branches/eam_branches/ipp-20110505/ippTools/share/laptool_definerun.sql	(revision 31587)
+++ branches/eam_branches/ipp-20110505/ippTools/share/laptool_definerun.sql	(revision 31628)
@@ -8,9 +8,17 @@
   ) AS want
   LEFT JOIN 
-  (SELECT exp_id,MAX(chip_id) AS chip_id
-     FROM lapExp 
+  (SELECT exp_id,MAX(chip_id) AS chip_id, chipRun.state
+     FROM lapExp JOIN chipRun USING(exp_id,chip_id) 
      where private IS FALSE 
      AND chip_id IS NOT NULL
-     AND active = TRUE ) AS have USING(exp_id)
+     AND 
+     	 (
+	  -- (active = TRUE) OR 
+	  (chipRun.state = 'full') OR
+	  (chipRun.state = 'new')
+	  -- when we can do updates, put that here.
+	  )
+     GROUP BY exp_id
+) AS have USING(exp_id)
      
 
Index: branches/eam_branches/ipp-20110505/ippTools/share/regtool_pendingimfile.sql
===================================================================
--- branches/eam_branches/ipp-20110505/ippTools/share/regtool_pendingimfile.sql	(revision 31587)
+++ branches/eam_branches/ipp-20110505/ippTools/share/regtool_pendingimfile.sql	(revision 31628)
@@ -8,8 +8,10 @@
     newImfile.uri,
     newImfile.bytes,
-    newImfile.md5sum
+    newImfile.md5sum,
+    summitExp.dateobs AS summit_dateobs
 FROM newImfile
 JOIN newExp
     USING(exp_id)
+JOIN summitExp USING(summit_id)
 LEFT JOIN rawImfile
     ON newExp.exp_id = rawImfile.exp_id
Index: branches/eam_branches/ipp-20110505/ippTools/src/addtool.c
===================================================================
--- branches/eam_branches/ipp-20110505/ippTools/src/addtool.c	(revision 31587)
+++ branches/eam_branches/ipp-20110505/ippTools/src/addtool.c	(revision 31628)
@@ -117,5 +117,5 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxcamGetSearchArgs (config, where);
+    //  pxcamGetSearchArgs (config, where);
     PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
     PXOPT_COPY_S64(config->args, where,  "-stack_id",    "stackRun.stack_id", "==");
@@ -123,7 +123,8 @@
     PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
     if (strcmp(stage, "cam")== 0) {
-
+      pxcamGetSearchArgs (config, where);
     pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
     pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
+
     PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
     }
@@ -133,4 +134,5 @@
     pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label
     PXOPT_COPY_STR(config->args, where,  "-reduction", "stackRun.reduction", "==");
+    pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
     }
     if (strcmp(stage, "staticsky")== 0) {
@@ -139,4 +141,5 @@
     pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
     PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyyRun.reduction", "==");
+    pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
     }
     
Index: branches/eam_branches/ipp-20110505/ippTools/src/addtoolConfig.c
===================================================================
--- branches/eam_branches/ipp-20110505/ippTools/src/addtoolConfig.c	(revision 31587)
+++ branches/eam_branches/ipp-20110505/ippTools/src/addtoolConfig.c	(revision 31628)
@@ -56,4 +56,5 @@
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by camRun label", NULL);
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-data_group", PS_META_DUPLICATE_OK, "search by camRun data_group", NULL);
+    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-filter", PS_META_DUPLICATE_OK, "search by filter", NULL);
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction",          0, "search by camRun reduction class", NULL);
     psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-destreaked",           0, "only queue destreaked runs", false);
Index: branches/eam_branches/ipp-20110505/ippTools/src/magictool.c
===================================================================
--- branches/eam_branches/ipp-20110505/ippTools/src/magictool.c	(revision 31587)
+++ branches/eam_branches/ipp-20110505/ippTools/src/magictool.c	(revision 31628)
@@ -404,5 +404,6 @@
     PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false);
     PXOPT_LOOKUP_BOOL(clearfault, config->args, "-clearfault", false);
-
+    PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);
+    
     psString setString = NULL;
     if (fault || clearfault) {
@@ -411,4 +412,7 @@
     if (note) {
         psStringAppend(&setString, ", note = '%s'", note);
+    }
+    if (label) {
+        psStringAppend(&setString, ", label = '%s'", label);
     }
 
Index: branches/eam_branches/ipp-20110505/ippTools/src/magictoolConfig.c
===================================================================
--- branches/eam_branches/ipp-20110505/ippTools/src/magictoolConfig.c	(revision 31587)
+++ branches/eam_branches/ipp-20110505/ippTools/src/magictoolConfig.c	(revision 31628)
@@ -81,4 +81,5 @@
     psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state (required)", NULL);
     psMetadataAddS16(updaterunArgs, PS_LIST_TAIL, "-set_fault", 0, "set fault code", 0);
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "define label", 0);
     psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_note",  0, "define note", NULL);
     psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-clearfault",  0, "set fault to zero", NULL);
