diff --git a/eos/db/__init__.py b/eos/db/__init__.py index 113e3f09d..70f2d6e4a 100755 --- a/eos/db/__init__.py +++ b/eos/db/__init__.py @@ -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:": diff --git a/eos/db/saveddata/queries.py b/eos/db/saveddata/queries.py index 13a88a852..98d5e9183 100755 --- a/eos/db/saveddata/queries.py +++ b/eos/db/saveddata/queries.py @@ -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.