IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32443


Ignore:
Timestamp:
Sep 23, 2011, 3:42:18 PM (15 years ago)
Author:
rhenders
Message:

including loaded_to_datastore = 1 when counting detections published; new method to count batches in time interval

File:
1 edited

Legend:

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

    r32436 r32443  
    218218               WHERE batch_type = '" + batchType + "' \
    219219               AND timestamp > '" + epoch + "' \
    220                AND dvo_db = '" + dvoGpc1Label + "'"
     220               AND dvo_db = '" + dvoGpc1Label + "' \
     221               AND processed = 1 \
     222               AND loaded_to_datastore = 1"
    221223
    222224        total = -1
     
    301303
    302304    '''
    303     Returns batches per hour. Simply goes back in time for the specified number of hours, so will return 0.0 if not loading
    304     '''
    305     def getBatchesPerHour(self, batchType, epoch, dvoGpc1Label, hours):
    306 
    307         sql = "SELECT COUNT(batch_id)/ " + str(hours) + " \
     305    Returns a count of batches processed in the specified time period.
     306    '''
     307    def countBatchesInLastPeriod(self, batchType, epoch, dvoGpc1Label, interval):
     308
     309        sql = "SELECT COUNT(batch_id) \
    308310               FROM batch \
    309311               WHERE batch_type = '" + batchType + "' \
     
    311313               AND timestamp > '" + epoch + "' \
    312314               AND dvo_db = '" + dvoGpc1Label + "' \
    313                AND timestamp > (now() - INTERVAL " +  str(hours) + " HOUR)"
    314 
    315         try:
    316             rs = self.executeQuery(sql)
    317             if rs.first(): return rs.getFloat(1)
    318         except:
    319             self.logger.exception("Unable to get batches per hour")
    320             return 0.0
     315               AND timestamp BETWEEN now() - INTERVAL " + interval + " AND now()"
     316
     317        try:
     318            rs = self.executeQuery(sql)
     319            if rs.first(): return rs.getInt(1)
     320        except:
     321            self.logger.exception("Unable to count batches in interval")
     322            return 0
    321323
    322324    '''
Note: See TracChangeset for help on using the changeset viewer.