Index: /trunk/tools/czartool/Gpc1Db.pm
===================================================================
--- /trunk/tools/czartool/Gpc1Db.pm	(revision 32062)
+++ /trunk/tools/czartool/Gpc1Db.pm	(revision 32063)
@@ -168,4 +168,31 @@
 ###########################################################################
 #
+# Returns count of exposures that have been registered
+#
+# NB JOINing summitExp to newExp to rawExp because summit_id is indexed, whereas
+# a direct JOIN from summitExp to rawExp using exp_name is more direct, but slower
+# as exp_name is not indexed in rawExp
+#
+###########################################################################
+sub countRegisteredExposures {
+    my ($self, $label, $date) = @_;
+
+    my $query = $self->{_db}->prepare(<<SQL);
+    SELECT COUNT(*) 
+        FROM summitExp 
+        JOIN newExp USING (summit_id) 
+        JOIN rawExp USING(exp_id) 
+        JOIN chipRun USING(exp_id) 
+        WHERE summitExp.dateobs > '$date' 
+        AND summitExp.exp_type = 'OBJECT' 
+        AND chipRun.label = "$label";
+SQL
+
+    $query->execute;
+    return scalar $query->fetchrow_array();
+}
+
+###########################################################################
+#
 # Returns count of exposures with this state for this label
 #
