Index: /trunk/ippToPsps/jython/metrics.py
===================================================================
--- /trunk/ippToPsps/jython/metrics.py	(revision 33672)
+++ /trunk/ippToPsps/jython/metrics.py	(revision 33673)
@@ -9,5 +9,4 @@
 from ipptopsps import IppToPsps
 from czardb import CzarDb
-from gpc1db import Gpc1Db
 from plot import Plot
 
@@ -25,7 +24,5 @@
         if len(sys.argv) > 2: self.parsePollTimeArg(sys.argv[2])
     
-        # create database objects
         self.czarDb = CzarDb(self.logger, self.config)
-        self.gpc1Db = Gpc1Db(self.logger, self.config)
         self.plot = Plot(self.logger, self.config, self.ippToPspsDb)
    
@@ -49,4 +46,5 @@
             rateP2 = self.printStats("P2")
             rateST = self.printStats("ST")
+            rateOB = self.printStats("OB")
             self.logger.info("+----+------------------+---------------+-------------------+------------------+----------------+")
         
@@ -56,9 +54,9 @@
             colCount = len(stages)
             self.writeTableSeparator(colCount)
-            sys.stdout.write("|Type|  DVO  ")
+            sys.stdout.write("|Type")
         
             for stage in stages: sys.stdout.write("|%19s" % stage)
             sys.stdout.write("|\n")
-            sys.stdout.write("|    |       ")
+            sys.stdout.write("|    ")
             for stage in stages: sys.stdout.write("| Pend  Succ  Fail  ")
             sys.stdout.write("|\n")
@@ -66,4 +64,5 @@
             pendP2Processed = self.printTableRow(stages, "P2")
             pendSTProcessed = self.printTableRow(stages, "ST")
+            pendOBProcessed = self.printTableRow(stages, "OB")
             self.writeTableSeparator(colCount)
 
@@ -73,4 +72,6 @@
             try: self.logger.infoPair("Estimated time for STs", "%.1f hours" % (pendSTProcessed / rateST)) 
             except: pass
+            try: self.logger.infoPair("Estimated time for OBs", "%.1f hours" % (pendOBProcessed / rateOB)) 
+            except: pass
        
             self.checkClientStatus()
@@ -79,5 +80,8 @@
             self.plot.createDensityPlot("P2", True)
             self.plot.createDensityPlot("ST", True)
+            self.plot.createDensityPlot("OB", True)
 
+            # some clean-up before going to sleep
+            self.ippToPspsDb.purgeDeadClients()
             if not self.waitForPollTime(): break
 
@@ -95,32 +99,19 @@
     def printTableRow(self, stages, batchType):
     
-        # get a master list of IDs in DVO for this batch type
-        rows = self.gpc1Db.getItemsInThisDVODbForThisStage(self.config.dvoLabel,
-                batchType, 
-                self.config.minRa, 
-                self.config.maxRa, 
-                self.config.minDec, 
-                self.config.maxDec)
+        pending = self.ippToPspsDb.getPendingIds(batchType)
 
-        # we only want to IDs
-        allIDs = []
-        for row in rows:
-            try: allIDs.append(row[0])
-            except: pass
-
-        #allIDs = self.ippToPspsDb.getPendingIdsForThisConfig(self.config.name)
-
-        prevList = allIDs
-        numEverything = len(allIDs)
-    
-        sys.stdout.write("| %2s |%6d " % (batchType, numEverything))
-    
-        tempFilename = batchType + '.dat'
+        sys.stdout.write("| %2s " % (batchType))
+   
+        firstStage = True
         for stage in stages:
     
            # get lists. Use unions with prev list to make sure the right stuff is included
-           success = list(set(self.ippToPspsDb.getStageIDs(batchType, self.config.epoch, self.config.dvoLabel, stage, 1)) & set(prevList)) 
-           fail = list(set(self.ippToPspsDb.getStageIDs(batchType, self.config.epoch, self.config.dvoLabel, stage, -1)) & set(prevList) - set(success))
-           pending = list(set(prevList) - set(success) - set(fail))
+           if firstStage:
+               success = self.ippToPspsDb.getStageIDs(batchType, stage, 1)
+               fail = list(set(self.ippToPspsDb.getStageIDs(batchType, stage, -1)) - set(success))
+           else: 
+               success = list(set(self.ippToPspsDb.getStageIDs(batchType, stage, 1)) & set(prevList)) 
+               fail = list(set(self.ippToPspsDb.getStageIDs(batchType, stage, -1)) & set(prevList) - set(success))
+               pending = list(set(prevList) - set(success) - set(fail))
     
            # count stuff
@@ -140,8 +131,10 @@
            prevList = success
     
-           self.czarDb.insertStats(stage, self.config.dvoLabel, batchType, numPending, numSuccess, numFail)
+           self.czarDb.insertStats(stage, self.config.name, batchType, numPending, numSuccess, numFail)
     
            if stage == 'processed': numPendingProcessed = numPending
     
+           firstStage = False
+
         sys.stdout.write("|\n")
     
@@ -153,5 +146,5 @@
     def writeTableSeparator(self, colCount):
     
-        sys.stdout.write("+----+-------")
+        sys.stdout.write("+----")
         for i in range(0, colCount): sys.stdout.write("+-------------------")
         sys.stdout.write("+\n")
@@ -169,9 +162,9 @@
     def printStats(self, batchType):
     
-        rate = self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel, "1 HOUR") / 1.0 
+        rate = self.ippToPspsDb.countBatches(batchType, "1 HOUR") / 1.0 
    
 
-        batchesInLast24Hours = self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel, "24 HOUR")
-        detectionsInLast24Hours = self.ippToPspsDb.getTotalDetectionsPublished(batchType, self.config.epoch, self.config.dvoLabel, "24 HOUR")
+        batchesInLast24Hours = self.ippToPspsDb.countBatches(batchType, "24 HOUR")
+        detectionsInLast24Hours = self.ippToPspsDb.getTotalDetectionsPublished(batchType, "24 HOUR")
 
         self.logger.info("| %2s | %16.1f | %13d | %17.1f | %16d | %14s |" % 
@@ -179,7 +172,7 @@
                  rate,
                  batchesInLast24Hours,
-                 self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel, "1 WEEK") / 7.0, 
+                 self.ippToPspsDb.countBatches(batchType, "1 WEEK") / 7.0, 
                  self.divide(detectionsInLast24Hours, batchesInLast24Hours),
-                 self.ippToPspsDb.getTimeOfLastBatchPublished(batchType, self.config.epoch, self.config.dvoLabel)))
+                 self.ippToPspsDb.getTimeOfLastBatchPublished(batchType)))
     
         return rate
