Index: trunk/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- trunk/ippToPsps/jython/ipptopspsdb.py	(revision 32362)
+++ trunk/ippToPsps/jython/ipptopspsdb.py	(revision 32436)
@@ -208,4 +208,29 @@
 
         return ids
+
+    '''
+    Returns the total detections published to the datastore for this epoch, dvo label and batch type
+    '''
+    def getTotalDetectionsPublished(self, batchType, epoch, dvoGpc1Label):
+
+        sql = "SELECT SUM(total_detections) \
+               FROM batch \
+               WHERE batch_type = '" + batchType + "' \
+               AND timestamp > '" + epoch + "' \
+               AND dvo_db = '" + dvoGpc1Label + "'"
+
+        total = -1
+        try:
+            rs = self.executeQuery(sql)
+            rs.first()
+            total =  rs.getInt(1)
+        except:
+            self.logger.exception("Can't query for total detections published")
+
+        rs.close()
+
+        self.logger.debug("Found %d detections" % total)
+
+        return total
 
     '''
@@ -273,5 +298,5 @@
     '''
     def getStages(self):
-        return ['processed', 'loaded_to_datastore', 'loaded_to_ODM', 'merge_worthy', 'merged', 'deleted_datastore', 'deleted_dxlayer', 'deleted_local']
+        return ['processed', 'loaded_to_datastore', 'loaded_to_ODM', 'merge_worthy', 'deleted_datastore', 'merged', 'deleted_dxlayer', 'deleted_local']
 
     '''
