Changeset 32353
- Timestamp:
- Sep 6, 2011, 1:35:45 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/ipptopspsdb.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/ipptopspsdb.py
r32292 r32353 245 245 246 246 ''' 247 TODO remove these 247 248 Series of getter methods that utilise getStageIDs() method above 248 249 ''' 249 250 def getProcessedIDs(self, batchType, epoch, dvoGpc1Label): 250 251 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): 252 255 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) 253 258 def getLoadedToODMIDs(self, batchType, epoch, dvoGpc1Label): 254 259 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) 255 262 def getMergeWorthyIDs(self, batchType, epoch, dvoGpc1Label): 256 263 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) 257 266 def getMergedIDs(self, batchType, epoch, dvoGpc1Label): 258 267 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 259 296 260 297 ''' … … 286 323 weeks = days/7.0 287 324 288 if minutes < 60: return "%.1f min utes ago" % minutes325 if minutes < 60: return "%.1f mins ago" % minutes 289 326 elif hours < 48: return "%.1f hours ago" % hours 290 327 elif days < 7: return "%.1f days ago" % days 291 328 return "%.1f weeks ago" % weeks 292 293 '''294 TODO295 '''296 def getBatchesPerDay(self, batchType, startTime, endTime=""):297 298 bph = self.getBatchesPerHour(batchType, startTime, endTime)299 return bph * 24300 301 '''302 TODO303 '''304 def getBatchesPerHour(self, batchType, startTime, endTime=""):305 306 bpm = self.getBatchesPerMinute(batchType, startTime, endTime)307 return bpm * 60308 309 '''310 TODO311 '''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 time326 327 '''328 TODO329 '''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 bpm344 329 345 330 '''
Note:
See TracChangeset
for help on using the changeset viewer.
