Skip to content

Commit

Permalink
#34: Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Sep 10, 2019
1 parent 0c9046a commit 957cf3a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,13 @@ def get_investigations_for_user_count(user_id, filters):
class InstrumentFacilityCyclesQuery(ReadQuery):
def __init__(self, instrument_id):
super().__init__(FACILITYCYCLE)
self.base_query = self.base_query.join(FACILITYCYCLE.FACILITY)\
.join(FACILITY.INSTRUMENT)\
.join(INSTRUMENT.INVESTIGATIONINSTRUMENT)\
.join(INVESTIGATIONINSTRUMENT.INVESTIGATION)\
.filter(INSTRUMENT.ID == instrument_id)\
.filter(INVESTIGATION.STARTDATE >= FACILITYCYCLE.STARTDATE)\
self.base_query = self.base_query\
.join(FACILITYCYCLE.FACILITY) \
.join(FACILITY.INSTRUMENT) \
.join(INSTRUMENT.INVESTIGATIONINSTRUMENT) \
.join(INVESTIGATIONINSTRUMENT.INVESTIGATION) \
.filter(INSTRUMENT.ID == instrument_id) \
.filter(INVESTIGATION.STARTDATE >= FACILITYCYCLE.STARTDATE) \
.filter(INVESTIGATION.STARTDATE <= FACILITYCYCLE.ENDDATE)


Expand All @@ -495,6 +496,7 @@ def get_facility_cycles_for_instrument(instrument_id, filters):
filter_handler = FilterOrderHandler()
return get_filtered_read_query_results(filter_handler, filters, query)


def get_facility_cycles_for_instrument_count(instrument_id, filters):
"""
Given an instrument_id get the facility cycles count where the instrument has investigations that occur within
Expand Down

0 comments on commit 957cf3a

Please sign in to comment.