Skip to content

Commit

Permalink
#34: Use joins on investigation user queries
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Sep 10, 2019
1 parent 957cf3a commit 266c644
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,8 @@ class UserInvestigationsQuery(ReadQuery):
"""

def __init__(self, user_id):
super().__init__(INVESTIGATIONUSER)
self.base_query = self.base_query.join(INVESTIGATION).filter(INVESTIGATIONUSER.USER_ID == user_id)

def get_all_results(self):
return list(map(lambda x: x.INVESTIGATION, super().get_all_results()))

def get_single_result(self):
return list(map(lambda x: x.INVESTIGATION, super().get_single_result()))
super().__init__(INVESTIGATION)
self.base_query = self.base_query.join(INVESTIGATIONUSER).filter(INVESTIGATIONUSER.USER_ID == user_id)


def get_investigations_for_user(user_id, filters):
Expand All @@ -450,8 +444,8 @@ class UserInvestigationsCountQuery(CountQuery):
"""

def __init__(self, user_id):
super().__init__(INVESTIGATIONUSER)
self.base_query = self.base_query.join(INVESTIGATION).filter(INVESTIGATIONUSER.USER_ID == user_id)
super().__init__(INVESTIGATION)
self.base_query = self.base_query.join(INVESTIGATIONUSER).filter(INVESTIGATIONUSER.USER_ID == user_id)


def get_investigations_for_user_count(user_id, filters):
Expand Down

0 comments on commit 266c644

Please sign in to comment.