Index: /trunk/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- /trunk/ippToPsps/jython/ipptopspsdb.py	(revision 32442)
+++ /trunk/ippToPsps/jython/ipptopspsdb.py	(revision 32443)
@@ -218,5 +218,7 @@
                WHERE batch_type = '" + batchType + "' \
                AND timestamp > '" + epoch + "' \
-               AND dvo_db = '" + dvoGpc1Label + "'"
+               AND dvo_db = '" + dvoGpc1Label + "' \
+               AND processed = 1 \
+               AND loaded_to_datastore = 1"
 
         total = -1
@@ -301,9 +303,9 @@
 
     '''
-    Returns batches per hour. Simply goes back in time for the specified number of hours, so will return 0.0 if not loading
-    '''
-    def getBatchesPerHour(self, batchType, epoch, dvoGpc1Label, hours):
-
-        sql = "SELECT COUNT(batch_id)/ " + str(hours) + " \
+    Returns a count of batches processed in the specified time period.
+    '''
+    def countBatchesInLastPeriod(self, batchType, epoch, dvoGpc1Label, interval):
+
+        sql = "SELECT COUNT(batch_id) \
                FROM batch \
                WHERE batch_type = '" + batchType + "' \
@@ -311,12 +313,12 @@
                AND timestamp > '" + epoch + "' \
                AND dvo_db = '" + dvoGpc1Label + "' \
-               AND timestamp > (now() - INTERVAL " +  str(hours) + " HOUR)"
-
-        try:
-            rs = self.executeQuery(sql)
-            if rs.first(): return rs.getFloat(1)
-        except:
-            self.logger.exception("Unable to get batches per hour")
-            return 0.0
+               AND timestamp BETWEEN now() - INTERVAL " + interval + " AND now()"
+
+        try:
+            rs = self.executeQuery(sql)
+            if rs.first(): return rs.getInt(1)
+        except:
+            self.logger.exception("Unable to count batches in interval")
+            return 0
 
     '''
