def delete_duplicates(entity): yield op.counters.Increment("total-counter") dupl_query = CrashReport.all(keys_only=True) dupl_query.filter('crashTime =', entity.crashTime) matched_crashes = dupl_query.fetch(50000) mustDelete = False counted = False matched = False if len(matched_crashes) > 1: for crkey in matched_crashes: cr = CrashReport.get(crkey) if cr.availableInternalMemory == entity.availableInternalMemory: matched = True if not counted: counted = True yield op.counters.Increment("individual-counter") if cr.sendTime < entity.sendTime: mustDelete = True break if mustDelete: yield op.counters.Increment("delete-counter") yield op.db.Delete(entity) else: if matched: yield op.counters.Increment("survivor-counter") else: yield op.counters.Increment("single-counter")
def recalc_counts_on_vesions(entity): crash_query = CrashReport.all(keys_only=True) crash_query.filter('versionName =', entity.name) crash_query.order('-crashTime') newcount = crash_query.count(20000) if entity.crashCount != newcount: entity.crashCount = newcount cr = CrashReport.get(crash_query.fetch(1)[0]) entity.lastIncident = cr.crashTime #logging.warning("Wrong count for bug %d, adjusting to %d" % entity.key().id(), count) yield op.counters.Increment("touched-versions") yield op.db.Put(entity) if newcount == 0: yield op.counters.Increment("empty-versions") yield op.counters.Increment("crash-counter", newcount)