def _get_comparison_discriminant(self, b): """Return a representative pair of converted revision from self and b. Order of the element on this pair is the same as the order of self relative to b. """ # SA occasionally uses comparison to check model instances # versus some sentinels, so we ensure we support comparison # against non-instances. if self.__class__ is not b.__class__: return (0, 1) # Pair converted revision from self and b. converted_revisions = map( lambda item: ( convert_revision( self.get_field(item), cache=Order.order_name_cache ), convert_revision( b.get_field(item), cache=Order.order_name_cache ), ), self.fields, ) # Return the first unequal pair, or (0, 0) otherwise. return next( itertools.dropwhile(lambda x: x[0] == x[1], converted_revisions), (0, 0), )
def __cmp__(self, b): # SA occasionally uses comparison to check model instances # verse some sentinels, so we ensure we support comparison # against non-instances. if self.__class__ is not b.__class__: return -1 # Compare every field in lexicographic order. return cmp([convert_revision(self.get_field(item), cache=Order.order_name_cache) for item in self.fields], [convert_revision(b.get_field(item), cache=Order.order_name_cache) for item in self.fields])
def __cmp__(self, b): # SA occasionally uses comparison to check model instances # verse some sentinels, so we ensure we support comparison # against non-instances. if self.__class__ is not b.__class__: return -1 # Compare every field in lexicographic order. return cmp([ convert_revision(self.get_field(item), cache=Order.order_name_cache) for item in self.fields ], [ convert_revision(b.get_field(item), cache=Order.order_name_cache) for item in self.fields ])
def __hash__(self): converted_fields = map( lambda item: convert_revision( self.get_field(item), cache=Order.order_name_cache ), self.fields, ) return hash(tuple(converted_fields))
def get(machine_id, test_id, field_index): """Get the data for a particular line in a graph.""" session = request.session ts = request.get_testsuite() # Maybe we don't need to do this? try: machine = session.query(ts.Machine) \ .filter(ts.Machine.id == machine_id) \ .one() test = session.query(ts.Test) \ .filter(ts.Test.id == test_id) \ .one() field = ts.sample_fields[field_index] except NoResultFound: abort(404) q = session.query(field.column, ts.Order.llvm_project_revision, ts.Run.start_time, ts.Run.id) \ .join(ts.Run) \ .join(ts.Order) \ .filter(ts.Run.machine_id == machine.id) \ .filter(ts.Sample.test == test) \ .filter(field.column.isnot(None)) \ .order_by(ts.Order.llvm_project_revision.desc()) if field.status_field: q = q.filter((field.status_field.column == PASS) | (field.status_field.column.is_(None))) limit = request.values.get('limit', None) if limit: limit = int(limit) if limit: q = q.limit(limit) samples = [[ convert_revision(rev), val, { 'label': rev, 'date': str(time), 'runID': str(rid) } ] for val, rev, time, rid in q.all()[::-1]] samples.sort(key=lambda x: x[0]) return samples
def get(machine_id, test_id, field_index): """Get the data for a particular line in a graph.""" session = request.session ts = request.get_testsuite() # Maybe we don't need to do this? try: machine = session.query(ts.Machine) \ .filter(ts.Machine.id == machine_id) \ .one() test = session.query(ts.Test) \ .filter(ts.Test.id == test_id) \ .one() field = ts.sample_fields[field_index] except NoResultFound: abort(404) q = session.query(field.column, ts.Order.llvm_project_revision, ts.Run.start_time, ts.Run.id) \ .join(ts.Run) \ .join(ts.Order) \ .filter(ts.Run.machine_id == machine.id) \ .filter(ts.Sample.test == test) \ .filter(field.column.isnot(None)) \ .order_by(ts.Order.llvm_project_revision.desc()) if field.status_field: q = q.filter((field.status_field.column == PASS) | (field.status_field.column.is_(None))) limit = request.values.get('limit', None) if limit: limit = int(limit) if limit: q = q.limit(limit) samples = [ [convert_revision(rev), val, {'label': rev, 'date': str(time), 'runID': str(rid)}] for val, rev, time, rid in q.all()[::-1] ] samples.sort(key=lambda x: x[0]) return samples