Skip to content

Commit

Permalink
Optimize code for less queries
Browse files Browse the repository at this point in the history
  • Loading branch information
sayanchowdhury committed Aug 22, 2016
1 parent b1fbee8 commit 00418af
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tahrir_api/dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def get_team(self, team_id):

if self.team_exists(team_id):
return self.session.query(Team).filter(
func.lower(Team.id) == func.lower(team_id)).one()
func.lower(Team.id) == func.lower(team_id)).first()
return None

@autocommit
Expand Down Expand Up @@ -240,9 +240,8 @@ def create_perk(self, position, badge_id, series_id):
:type series_id: str
:param series_id: ID of the Series
"""
if self.perk_exists_for_badge_series(badge_id, series_id):
perk = self.get_perk_from_badge_series(badge_id, series_id).first()
else:
perk = self.get_perk_from_badge_series(badge_id, series_id).first()
if not perk:
perk = Perk(position=position,
badge_id=badge_id,
series_id=series_id)
Expand Down

0 comments on commit 00418af

Please sign in to comment.