Index: trunk/ippToPsps/jython/ipptopspsdb.py
===================================================================
--- trunk/ippToPsps/jython/ipptopspsdb.py	(revision 32001)
+++ trunk/ippToPsps/jython/ipptopspsdb.py	(revision 32002)
@@ -59,10 +59,11 @@
     TODO
     '''
-    def getProcessedIDsForThisStage(self, batchType, startDate):
+    def getProcessedIDsForThisStage(self, batchType, epoch, dvoGpc1Label):
 
         sql = "SELECT DISTINCT stage_id \
                FROM batch \
                WHERE batch_type = '" + batchType + "' \
-               AND timestamp > '" + startDate + "' \
+               AND timestamp > '" + epoch + "' \
+               AND dvo_db = '" + dvoGpc1Label + "' \
                AND loaded_to_datastore"
 
@@ -157,10 +158,11 @@
     TODO
     '''
-    def getFailedBatches(self, batchType, startTime, endTime=""):
+    def getFailedBatches(self, batchType, epoch, dvoGpc1Label):
 
         sql = "SELECT DISTINCT stage_id \
                FROM batch \
-               WHERE timestamp > '" + startTime + "' \
+               WHERE timestamp > '" + epoch + "' \
                AND batch_type = '" + batchType + "' \
+               AND dvo_db = '" + dvoGpc1Label + "' \
                AND !processed"
 
Index: trunk/ippToPsps/jython/metrics.py
===================================================================
--- trunk/ippToPsps/jython/metrics.py	(revision 32001)
+++ trunk/ippToPsps/jython/metrics.py	(revision 32002)
@@ -17,6 +17,6 @@
 
     allIDs = gpc1Db.getIDsInThisDVODbForThisStage(dvoGpc1Label, batchType)
-    processedIDs = ippToPspsDb.getProcessedIDsForThisStage(batchType, epoch)
-    failedIDs = ippToPspsDb.getFailedBatches(batchType, epoch)
+    processedIDs = ippToPspsDb.getProcessedIDsForThisStage(batchType, epoch, dvoGpc1Label)
+    failedIDs = ippToPspsDb.getFailedBatches(batchType, epoch, dvoGpc1Label)
     unprocessedIDs = list(set(allIDs) - set(processedIDs))
 
@@ -25,5 +25,5 @@
                 len(allIDs), 
                 len(processedIDs), 
-                len(list(set(failedIDs) - set(allIDs))), 
+                len(list(set(failedIDs) - set(processedIDs))), 
                 len(unprocessedIDs), 
                 ippToPspsDb.getLastBatchPublished(batchType)))
