IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31864


Ignore:
Timestamp:
Jul 12, 2011, 9:46:19 AM (15 years ago)
Author:
rhenders
Message:

new method for getting IDs of all failed batches

File:
1 edited

Legend:

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

    r31861 r31864  
    6161    def getProcessedIDsForThisStage(self, batchType, startDate):
    6262
    63         sql = "SELECT stage_id \
     63        sql = "SELECT DISTINCT stage_id \
    6464               FROM batch \
    6565               WHERE batch_type = '" + batchType + "' \
     
    157157    TODO
    158158    '''
    159     def getTotalFailedBatches(self, batchType, startTime, endTime=""):
    160 
    161         sql = "SELECT COUNT(DISTINCT stage_id) \
     159    def getFailedBatches(self, batchType, startTime, endTime=""):
     160
     161        sql = "SELECT DISTINCT stage_id \
    162162               FROM batch \
    163163               WHERE timestamp > '" + startTime + "' \
    164164               AND batch_type = '" + batchType + "' \
    165                AND !processed \
    166                AND stage_id NOT IN \
    167                (SELECT DISTINCT stage_id \
    168                 FROM batch \
    169                 WHERE timestamp > '" + startTime + "'  \
    170                 AND batch_type = '" + batchType + "' \
    171                 AND loaded_to_datastore)"
    172 
    173         try:
    174             rs = self.executeQuery(sql)
    175             rs.first()
    176             total = rs.getInt(1)
    177         except:
    178             self.logger.exception("Unable to count failed batches")
    179 
    180         return total
    181     '''
    182     TODO
    183     '''
    184     def getTotalBatchesPublished(self, batchType, startTime, endTime=""):
    185 
    186         sql = "SELECT COUNT(*) \
    187                FROM batch \
    188                WHERE timestamp > '" + startTime + "' \
    189                AND batch_type = '" + batchType + "' \
    190                AND loaded_to_datastore"
    191 
    192         try:
    193             rs = self.executeQuery(sql)
    194             rs.first()
    195             total = rs.getInt(1)
    196         except:
    197             self.logger.exception("Unable to count batches")
    198 
    199         return total
     165               AND !processed"
     166
     167        ids = []
     168        try:
     169            rs = self.executeQuery(sql)
     170            while (rs.next()):
     171                ids.append(rs.getInt(1))
     172        except:
     173            self.logger.exception("Can't query for failed ids in ipptopsps Db")
     174
     175        rs.close()
     176
     177        self.logger.debug("Found %d failed items for batchType='%s'" % (len(ids), batchType))
     178
     179        return ids
    200180
    201181    '''
Note: See TracChangeset for help on using the changeset viewer.