Added getFitsWithBooster query

This commit is contained in:
blitzmann
2014-02-21 21:47:10 -05:00
parent 7579f3c3e1
commit 46662d2b72
2 changed files with 19 additions and 1 deletions

View File

@@ -66,7 +66,7 @@ from eos.db.saveddata.queries import getUser, getCharacter, getFit, getFitsWithS
getCharacterList, getPrice, getDamagePatternList, getDamagePattern, \
getFitList, getFleetList, getFleet, save, remove, commit, add, \
getCharactersForUser, getMiscData, getSquadsIDsWithFitID, getWing, \
getSquad
getSquad, getFitsWithBooster
#If using in memory saveddata, you'll want to reflect it so the data structure is good.
if config.saveddata_connectionstring == "sqlite:///:memory:":

View File

@@ -248,6 +248,24 @@ def getFitsWithShip(shipID, ownerID=None, where=None, eager=None):
raise TypeError("ShipID must be integer")
return fits
def getFitsWithBooster(ownerID=None, where=None, eager=None):
"""
Get all the fits that are flagged as a boosting ship
If no user is passed, do this for all users.
"""
if ownerID is not None and not isinstance(ownerID, int):
raise TypeError("OwnerID must be integer")
filter = Fit.booster == 1
if ownerID is not None:
filter = and_(filter, Fit.ownerID == ownerID)
filter = processWhere(filter, where)
eager = processEager(eager)
with sd_lock:
fits = saveddata_session.query(Fit).options(*eager).filter(filter).all()
return fits
def countFitsWithShip(shipID, ownerID=None, where=None, eager=None):
"""
Get all the fits using a certain ship.