def sequence_group_tag_field(selected=None, empty='--'): if not wowo('contractor'): tag_q = Session.query(SequenceGroupTag).order_by(SequenceGroupTag.name) tags = tag_q.all() else: tags = [] return {'value': selected or '', 'options': [('',empty)]+[(tag.id, tag.name) for tag in tags]}
def total_events(): plate_query = Session.query(QLBPlate, func.sum(QLBWell.event_count).label('total_count')).\ join(QLBWell).\ join(QLBPlate.plate).\ join(Plate.box2).\ filter(and_(QLBPlate.plate_id != None, QLBWell.file_id != None)).\ group_by(QLBWell.plate_id) if wowo('contractor'): plate_query = plate_query.filter(Box2.prod_query()) return sum([total_count or 0 for plate, total_count in plate_query.all()])
def dr_url(box2, **kwargs): if not wowo('dr_subdomains'): return url(**kwargs) subdomain = get_dr_subdomain(box2) if not subdomain: return url(**kwargs) else: kwargs['qualified'] = True # because I can't get the Routes subdomain URL bullcrap to work kwargs['host'] = subdomain return url(**kwargs)
def wrapper(self, *args, **kwargs): if wowo("contractor"): id = kwargs.get("id") if id is None: abort(404, "Error: no plate id.") plate = Session.query(Plate).get(id) if not plate: abort(404, 'Plate id error. got "%s"' % str(id)) box2 = plate.box2 if not box2.is_prod or plate.onsite: abort(403) return func.__call__(self, *args, **kwargs)
def time_events(start, end): plate_query = QLBPlate.filter_by_host_datetime(Session.query(QLBPlate, func.sum(QLBWell.event_count).label('total_count')). join(QLBWell).\ join(QLBPlate.plate).\ join(Plate.box2).\ filter(and_(QLBPlate.plate_id != None, QLBWell.file_id != None)), start, end) if wowo('contractor'): plate_query = plate_query.filter(Box2.prod_query()) return sum([total_count or 0 for plate, total_count in plate_query.all()])
def wrapper(self, *args, **kwargs): if wowo("contractor"): id = kwargs.get("id") well = ( Session.query(QLBWell) .filter(QLBWell.id == id) .options(joinedload_all(QLBWell.plate, QLBPlate.plate, Plate.box2, innerjoin=True)) .first() ) if not well: abort(404) if not well.plate.plate.box2.is_prod or well.plate.plate.onsite: abort(403) return func(self, *args, **kwargs)
def box2_field(selected=None, empty='--', prod_only=False, exclude_fluidics_modules=False,order_by='name',order_desc=False): if ( order_desc ): box_q = Session.query(Box2).order_by( getattr(Box2,order_by).desc() ) else: box_q = Session.query(Box2).order_by( getattr(Box2,order_by) ) if prod_only or wowo('contractor'): box_q = box_q.filter(Box2.prod_query()) if exclude_fluidics_modules: box_q = box_q.filter(Box2.whole_readers_only_query()) boxes = box_q.all() return {'value': selected or '', 'options': [('',empty)]+ [(box.id, box.name) for box in boxes]}
def project_field(selected=None, active_only=False, validation_only=False, empty='--'): if not wowo('contractor'): project_q = Session.query(Project).order_by(Project.name) if active_only: project_q = project_q.filter(Project.active == True) # should prob fix this... if validation_only: project_q = project_q.filter(or_(Project.name.like('%Beta%'), Project.name.like('%Validation%'), Project.name.like('%Alpha%'))) projects = project_q.all() else: projects = [] return {'value': selected or '', 'options': [('',empty)]+[(project.id, project.name) for project in projects]}
def plate_runtimes_for_operator_range(start, end): plate_query = QLBPlate.filter_by_host_datetime(Session.query(QLBPlate, func.count(QLBWell).label('wells'), func.sum(func.if_(QLBWell.event_count >= 1000, 1, 0)).label('data_wells'), func.sum(QLBWell.event_count).label('data_well_events')). join(QLBWell).\ join(QLBPlate.plate).\ join(Plate.box2).\ filter(and_(QLBPlate.plate_id != None, QLBWell.file_id != None)), start, end).group_by(QLBWell.plate_id).options(joinedload_all('plate.box2', innerjoin=True), joinedload_all('plate.operator')) if wowo('contractor'): plate_query = plate_query.filter(Box2.prod_query()) return plate_query.all()
def plate_runtimes_for_box_range(start, end): plate_query = QLBPlate.filter_by_host_datetime(Session.query(QLBPlate, func.min(QLBWell.host_datetime).label('start_time'), func.max(QLBWell.host_datetime).label('end_time')). join(QLBWell).\ join(QLBPlate.plate).\ join(Plate.box2).\ filter(and_(QLBPlate.plate_id != None, QLBWell.file_id != None)), start, end).group_by(QLBWell.plate_id).options(joinedload_all('plate.box2', innerjoin=True), joinedload_all('plate.operator')) if wowo('contractor'): plate_query = plate_query.filter(Box2.prod_query()) runtimes = plate_query.all() # TODO: engineer quick fix for this return [runtime for runtime in runtimes if runtime.start_time and runtime.end_time]
def lab_reader_group_field(empty='--'): """ Intended to be set in a manual environment. Should be ported to a Bootstrap-type scheme like comparable_metric_field() """ box_q = Session.query(Box2).order_by(Box2.name) lab_readers = box_q.filter(Box2.lab_query()).all() prod_readers = box_q.filter(Box2.prod_query()).all() # htmlfill-compatible. if not wowo('contractor'): return [('',empty), ([(box.id, box.name) for box in lab_readers], 'Lab'), ([(box.id, box.name) for box in prod_readers],'Production')] else: return [('',empty), ([(box.id, box.name) for box in prod_readers],'Production')]
def __inhouse_readers(self, admin=True): if wowo('contractor'): return [] # redmine 875 -- fix this with single flag box2_query = Session.query(Box2).filter(or_(Box2.name.like('Alpha 0%'), Box2.name.like('Beta 0%'), Box2.name.like('Beta 1%'), Box2.name.like('ENG%'), Box2.name.like('GXD%'), Box2.name.like('RevC %'))).order_by(Box2.name) c.admin = admin != 'False' if not c.admin: box2_query = box2_query.filter_by(active=True) box2s = box2_query.all() return box2s
def wrapper(self, *args, **kwargs): if wowo("contractor"): abort(403) else: return func.__call__(self, *args, **kwargs)