IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32353


Ignore:
Timestamp:
Sep 6, 2011, 1:35:45 PM (15 years ago)
Author:
rhenders
Message:

removed some redundant metrics queries; new method to get batches-per-hour

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/ipptopspsdb.py

    r32292 r32353  
    245245
    246246    '''
     247    TODO remove these
    247248    Series of getter methods that utilise getStageIDs() method above
    248249    '''
    249250    def getProcessedIDs(self, batchType, epoch, dvoGpc1Label):
    250251        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "processed", 1)
    251     def getloadedToDatastoreIDs(self, batchType, epoch, dvoGpc1Label):
     252    def getFailedProcessedIDs(self, batchType, epoch, dvoGpc1Label):
     253        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "processed", -1)
     254    def getLoadedToDatastoreIDs(self, batchType, epoch, dvoGpc1Label):
    252255        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "loaded_to_datastore", 1)
     256    def getFailedLoadedToDatastoreIDs(self, batchType, epoch, dvoGpc1Label):
     257        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "loaded_to_datastore", -1)
    253258    def getLoadedToODMIDs(self, batchType, epoch, dvoGpc1Label):
    254259        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "loaded_to_ODM", 1)
     260    def getFailedLoadedToODMIDs(self, batchType, epoch, dvoGpc1Label):
     261        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "loaded_to_ODM", -1)
    255262    def getMergeWorthyIDs(self, batchType, epoch, dvoGpc1Label):
    256263        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "merge_worthy", 1)
     264    def getFailedMergeWorthyIDs(self, batchType, epoch, dvoGpc1Label):
     265        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "merge_worthy", -1)
    257266    def getMergedIDs(self, batchType, epoch, dvoGpc1Label):
    258267        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "merged", 1)
     268    def getFailedMergedIDs(self, batchType, epoch, dvoGpc1Label):
     269        return self.getStageIDs(batchType, epoch, dvoGpc1Label, "merged", -1)
     270
     271    '''
     272    Returns a list of stages
     273    '''
     274    def getStages(self):
     275        return ['processed', 'loaded_to_datastore', 'loaded_to_ODM', 'merge_worthy', 'merged', 'deleted_local', 'deleted_datastore', 'deleted_dxlayer']
     276
     277    '''
     278    Returns batches per hour
     279    '''
     280    def getBatchesPerHour(self, batchType, epoch, dvoGpc1Label, hours):
     281
     282        sql = "SELECT COUNT(batch_id)/ " + str(hours) + " \
     283               FROM batch \
     284               WHERE batch_type = '" + batchType + "' \
     285               AND processed = 1 \
     286               AND timestamp > '" + epoch + "' \
     287               AND dvo_db = '" + dvoGpc1Label + "' \
     288               AND timestamp > (now() - INTERVAL " +  str(hours) + " HOUR)"
     289
     290        try:
     291            rs = self.executeQuery(sql)
     292            if rs.first(): return rs.getFloat(1)
     293        except:
     294            self.logger.exception("Unable to get batches per hour")
     295            return 0.0
    259296
    260297    '''
     
    286323        weeks = days/7.0
    287324
    288         if minutes < 60: return "%.1f minutes ago" % minutes
     325        if minutes < 60: return "%.1f mins ago" % minutes
    289326        elif hours < 48: return "%.1f hours ago" % hours
    290327        elif days < 7: return "%.1f days ago" % days
    291328        return "%.1f weeks ago" % weeks
    292 
    293     '''
    294     TODO
    295     '''
    296     def getBatchesPerDay(self, batchType, startTime, endTime=""):
    297 
    298         bph = self.getBatchesPerHour(batchType, startTime, endTime)
    299         return bph * 24
    300 
    301     '''
    302     TODO
    303     '''
    304     def getBatchesPerHour(self, batchType, startTime, endTime=""):
    305 
    306         bpm = self.getBatchesPerMinute(batchType, startTime, endTime)
    307         return bpm * 60
    308 
    309     '''
    310     TODO
    311     '''
    312     def getAverageTimePerBatch(self, batchType, startTime, endTime=""):
    313 
    314         sql = "SELECT (TIMESTAMPDIFF(MINUTE, min(timestamp), max(timestamp)) / COUNT(*)) \
    315                FROM batch \
    316                WHERE timestamp > '" + startTime + "' and batch_type = '" + batchType + "'"
    317 
    318         try:
    319             rs = self.executeQuery(sql)
    320             rs.first()
    321             time = rs.getDouble(1)
    322         except:
    323             self.logger.exception("Unable to get batches per minute")
    324 
    325         return time
    326 
    327     '''
    328     TODO
    329     '''
    330     def getBatchesPerMinute(self, batchType, startTime, endTime=""):
    331 
    332         sql = "SELECT (count(*) / TIMESTAMPDIFF(MINUTE, min(timestamp), max(timestamp)) ) \
    333                FROM batch \
    334                WHERE timestamp > '" + startTime + "' and batch_type = '" + batchType + "'"
    335 
    336         try:
    337             rs = self.executeQuery(sql)
    338             rs.first()
    339             bpm = rs.getDouble(1)
    340         except:
    341             self.logger.exception("Unable to get batches per minute")
    342 
    343         return bpm
    344329
    345330    '''
Note: See TracChangeset for help on using the changeset viewer.