IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32541


Ignore:
Timestamp:
Oct 13, 2011, 9:50:28 AM (15 years ago)
Author:
rhenders
Message:

no need for 'DISTINCT batch_id as that column is an index, so they are all distinct anyway; new methid to get batches that are not merge-worthy; new method to get all 'unfinished' batches, i.e. everything that is not merged and not failed;

File:
1 edited

Legend:

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

    r32518 r32541  
    5959               AND batch_type = '" + batchType + "' \
    6060               AND dvo_db = '" + dvoGpc1Label + "' \
    61                AND loaded_to_ODM != 0 \
     61               AND (loaded_to_ODM = -1 OR merge_worthy = 1) \
    6262               AND " + column + " = 0"
    6363
     
    129129
    130130    '''
    131     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
     131    Returns a list of processed batch IDs that either not yet loaded to the ODM or not merge_worthy or not merged
     132    NOTE we exclude batches already deleted from the datastore, as sometimes we delete stuff prior to loading to ODM if there is a known problem with the batch
     133    '''
     134    def getAllUnfinishedBatchIDs(self, epoch, dvoGpc1Label, batchType):
     135
     136        sql = "SELECT batch_id \
     137               FROM batch \
     138               WHERE timestamp > '" + epoch + "' \
     139               AND dvo_db = '" + dvoGpc1Label + "' \
     140               AND loaded_to_datastore = 1 \
     141               AND batch_type = '" + batchType + "' \
     142               AND deleted_datastore = 0 \
     143               AND loaded_to_ODM != -1 \
     144               AND merge_worthy != -1 \
     145               AND merged = 0"
     146
     147        ids = []
     148        try:
     149            rs = self.executeQuery(sql)
     150            while (rs.next()):
     151                ids.append(rs.getInt(1))
     152        except:
     153            self.logger.exception("Can't query for unloaded batch ids in ipptopsps Db")
     154
     155        rs.close()
     156
     157        self.logger.debug("Found %d unloaded items" % len(ids))
     158
     159        return ids
     160
     161    '''
     162    Returns a list of processed batch IDs that are not yet loaded to the ODM
     163    NOTE we exclude batches already deleted from the datastore, as sometimes we delete stuff prior to loading to ODM if there is a known problem with the batch
    134164    '''
    135165    def getUnloadedBatchIDs(self, epoch, dvoGpc1Label, batchType):
    136166
    137         sql = "SELECT DISTINCT batch_id \
     167        sql = "SELECT batch_id \
    138168               FROM batch \
    139169               WHERE timestamp > '" + epoch + "' \
     
    159189
    160190    '''
     191    Returns a list of processed batch IDs that are not yet merge_worthy and that have not failed to load
     192    NOTE we exclude batches already deleted from the datastore, as sometimes we delete stuff prior to loading to ODM if there is a known problem with the batch
     193    '''
     194    def getUnmergeWorthyBatchIDs(self, epoch, dvoGpc1Label, batchType):
     195
     196        sql = "SELECT batch_id \
     197               FROM batch \
     198               WHERE timestamp > '" + epoch + "' \
     199               AND dvo_db = '" + dvoGpc1Label + "' \
     200               AND loaded_to_datastore = 1 \
     201               AND batch_type = '" + batchType + "' \
     202               AND merge_worthy = 0 \
     203               AND loaded_to_ODM != -1 \
     204               AND deleted_datastore = 0"
     205
     206        ids = []
     207        try:
     208            rs = self.executeQuery(sql)
     209            while (rs.next()):
     210                ids.append(rs.getInt(1))
     211        except:
     212            self.logger.exception("Can't query for un-mergeworthy batch ids in ipptopsps Db")
     213
     214        rs.close()
     215
     216        self.logger.debug("Found %d unloaded items" % len(ids))
     217
     218        return ids
     219
     220    '''
    161221    Returns a list of processed batch IDs that are merge_worthy, but not yet merged, for this epoch and dvo label
    162222    '''
    163223    def getUnmergedBatchIDs(self, epoch, dvoGpc1Label, batchType):
    164224
    165         sql = "SELECT DISTINCT batch_id \
    166                FROM batch \
    167                WHERE timestamp > '" + epoch + "' \
    168                AND dvo_db = '" + dvoGpc1Label + "' \
    169                AND loaded_to_ODM = 1 \
     225        sql = "SELECT batch_id \
     226               FROM batch \
     227               WHERE timestamp > '" + epoch + "' \
     228               AND dvo_db = '" + dvoGpc1Label + "' \
     229               AND merge_worthy = 1 \
    170230               AND batch_type = '" + batchType + "' \
    171231               AND merged != 1"
Note: See TracChangeset for help on using the changeset viewer.