IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32496


Ignore:
Timestamp:
Oct 5, 2011, 5:04:07 PM (15 years ago)
Author:
rhenders
Message:

new method that returns the batch type for the provided batch ID; using getLong(), rather than getInt(), when finding total detections; changes to methods that return unmerged or not yet merge_worthy batches

File:
1 edited

Legend:

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

    r32461 r32496  
    2323
    2424    '''
    25     Returns a list of processed batch IDs that are merged but not yet deleted
     25    Returns a list of merged batch IDs that are merged but not yet deleted
     26    '''
     27    def getMergedButNotDeletedBatchIDs(self, batchType, epoch, dvoGpc1Label, column):
     28
     29        sql = "SELECT DISTINCT batch_id \
     30               FROM batch \
     31               WHERE timestamp > '" + epoch + "' \
     32               AND batch_type = '" + batchType + "' \
     33               AND dvo_db = '" + dvoGpc1Label + "' \
     34               AND merged = 1 \
     35               AND " + column + " = 0"
     36
     37        ids = []
     38        try:
     39            rs = self.executeQuery(sql)
     40            while (rs.next()):
     41                ids.append(rs.getInt(1))
     42        except:
     43            self.logger.exception("Can't query for merged batch ids in ipptopsps Db")
     44
     45        rs.close()
     46
     47        self.logger.debug("Found %d merged but un-deleted items" % len(ids))
     48
     49        return ids
     50
     51    '''
     52    Returns a list of processed batch IDs that have been loaded to the ODM but not yet deleted
    2653    '''
    2754    def getLoadedToODMButNotDeletedBatchIDs(self, batchType, epoch, dvoGpc1Label, column):
     
    5077
    5178    '''
    52     Returns a list of processed batch IDs that are merged but not deleted from local disk
     79    Returns a list of merged batch IDs that are not deleted from local disk
     80    '''
     81    def getMergedButNotDeletedFromLocalDisk(self, batchType, epoch, dvoGpc1Label):
     82        return self.getMergedButNotDeletedBatchIDs(batchType, epoch, dvoGpc1Label, "deleted_local")
     83
     84    '''
     85    Returns a list of processed batch IDs that are loaded to the ODM, but not deleted from local disk
    5386    '''
    5487    def getLoadedToODMButNotDeletedFromLocalDisk(self, batchType, epoch, dvoGpc1Label):
     
    5689
    5790    '''
    58     Returns a list of processed batch IDs that are merged but not deleted from datastore
     91    Returns a list of processed batch IDs that are loaded to the ODM, but not deleted from datastore
    5992    '''
    6093    def getLoadedToODMButNotDeletedFromDatastore(self, batchType, epoch, dvoGpc1Label):
     
    6295
    6396    '''
    64     Returns a list of processed batch IDs that are merged but not deleted from DXLayer
     97    Returns a list of processed batch IDs that are loaded to the ODM, but not deleted from DXLayer
    6598    '''
    6699    def getLoadedToODMButNotDeletedFromDXLayer(self, batchType, epoch, dvoGpc1Label):
     
    97130    '''
    98131    Returns a list of processed batch IDs that have not yet been loaded to the ODM
     132    NOTE we exclude batches already deleted from the datastore, as sometimes we delete stuff prior to
     133    loading to ODM if there is a known problem with the batch
    99134    '''
    100135    def getUnloadedBatchIDs(self, epoch, dvoGpc1Label, batchType):
     
    106141               AND loaded_to_datastore = 1 \
    107142               AND batch_type = '" + batchType + "' \
    108                AND loaded_to_ODM = 0"
    109 
     143               AND loaded_to_ODM = 0 \
     144               AND deleted_datastore = 0"
    110145
    111146        ids = []
     
    192227            rs = self.executeQuery(sql)
    193228            rs.first()
    194             total =  rs.getInt(1)
     229            total =  rs.getLong(1)
    195230        except:
    196231            self.logger.exception("Can't query for total detections published")
     
    266301    '''
    267302    def getStages(self):
    268         return ['processed', 'loaded_to_datastore', 'loaded_to_ODM', 'merge_worthy', 'deleted_datastore', 'merged', 'deleted_dxlayer', 'deleted_local']
     303        return ['processed', 'loaded_to_datastore', 'loaded_to_ODM', 'merge_worthy', 'deleted_datastore', 'merged', 'deleted_local', 'deleted_dxlayer']
    269304
    270305    '''
     
    414449        except:
    415450            self.logger.exception("Unable to check whether this batch is being processed")
     451
     452    '''
     453    Gets the batch type of this batch
     454    '''
     455    def getBatchType(self, batch_id):
     456
     457        sql = "SELECT batch_type \
     458               FROM batch \
     459               WHERE batch_id = " + str(batch_id)
     460
     461        batch_type = "NA"
     462        try:
     463            rs = self.executeQuery(sql)
     464            rs.first()
     465            batch_type = rs.getString(1)
     466        except:
     467            self.logger.exception("Unable to check whether this batch has already been processed")
     468 
     469        return batch_type
    416470
    417471    '''
Note: See TracChangeset for help on using the changeset viewer.