def getVariations(itemids, groupIDs=None, where=None, eager=None): for itemid in itemids: if not isinstance(itemid, int): raise TypeError("All passed item IDs must be integers") # Get out if list of provided IDs is empty if len(itemids) == 0: return [] itemfilter = or_(*(metatypes_table.c.parentTypeID == itemid for itemid in itemids)) filter = processWhere(itemfilter, where) joinon = items_table.c.typeID == metatypes_table.c.typeID vars = gamedata_session.query(Item).options(*processEager(eager)).join( (metatypes_table, joinon)).filter(filter).all() if vars: return vars elif groupIDs: itemfilter = or_(*(groups_table.c.groupID == groupID for groupID in groupIDs)) filter = processWhere(itemfilter, where) joinon = items_table.c.groupID == groups_table.c.groupID vars = gamedata_session.query(Item).options(*processEager(eager)).join( (groups_table, joinon)).filter(filter).all() return vars
def countFitsWithShip(lookfor, ownerID=None, where=None, eager=None): """ Get all the fits using a certain 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") if isinstance(lookfor, int): filter = Fit.shipID == lookfor elif isinstance(lookfor, list): if len(lookfor) == 0: return 0 filter = Fit.shipID.in_(lookfor) else: raise TypeError("You must supply either an integer or ShipID must be integer") if ownerID is not None: filter = and_(filter, Fit.ownerID == ownerID) filter = processWhere(filter, where) eager = processEager(eager) with sd_lock: count = saveddata_session.query(Fit).options(*eager).filter(filter).count() return count
def countFitsWithShip(lookfor, ownerID=None, where=None, eager=None): """ Get all the fits using a certain 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") if isinstance(lookfor, int): filter = Fit.shipID == lookfor elif isinstance(lookfor, list): if len(lookfor) == 0: return 0 filter = Fit.shipID.in_(lookfor) else: raise TypeError( "You must supply either an integer or ShipID must be integer") if ownerID is not None: filter = and_(filter, Fit.ownerID == ownerID) filter = processWhere(filter, where) eager = processEager(eager) with sd_lock: count = saveddata_session.query(Fit).options( *eager).filter(filter).count() return count
def getItemsByCategory(filter, where=None, eager=None): if isinstance(filter, int): filter = Category.ID == filter elif isinstance(filter, basestring): filter = Category.name == filter else: raise TypeError("Need integer or string as argument") filter = processWhere(filter, where) return gamedata_session.query(Item).options(*processEager(eager)).join(Item.group, Group.category).filter(filter).all()
def searchFits(nameLike, where=None, eager=None): if not isinstance(nameLike, basestring): raise TypeError("Need string as argument") # Prepare our string for request nameLike = u"%{0}%".format(sqlizeString(nameLike)) #Add any extra components to the search to our where clause filter = processWhere(Fit.name.like(nameLike, escape="\\"), where) eager = processEager(eager) with sd_lock: fits = saveddata_session.query(Fit).options(*eager).filter(filter).all() return fits
def getVariations(itemids, where=None, eager=None): for itemid in itemids: if not isinstance(itemid, int): raise TypeError("All passed item IDs must be integers") # Get out if list of provided IDs is empty if len(itemids) == 0: return [] itemfilter = or_(*(metatypes_table.c.parentTypeID == itemid for itemid in itemids)) filter = processWhere(itemfilter, where) joinon = items_table.c.typeID == metatypes_table.c.typeID vars = gamedata_session.query(Item).options(*processEager(eager)).join((metatypes_table, joinon)).filter(filter).all() return vars
def getVariations(itemids, where=None, eager=None): for itemid in itemids: if not isinstance(itemid, int): raise TypeError("All passed item IDs must be integers") # Get out if list of provided IDs is empty if len(itemids) == 0: return [] itemfilter = or_(*(Mapper.Items.metatypes_table.c.parentTypeID == itemid for itemid in itemids)) filter = processWhere(itemfilter, where) joinon = Mapper.Items.items_table.c.typeID == Mapper.Items.metatypes_table.c.typeID vars = sqlAlchemy.gamedata_session.query(Item).options(*processEager(eager)).join( (Mapper.Items.metatypes_table, joinon)).filter( filter).all() return vars
def searchItems(nameLike, where=None, join=None, eager=None): if not isinstance(nameLike, basestring): raise TypeError("Need string as argument") # Prepare our string for request nameLike = u"%{0}%".format(sqlizeString(nameLike)) if join is None: join = tuple() if not hasattr(join, "__iter__"): join = (join,) filter = processWhere(Item.name.like(nameLike, escape="\\"), where) items = gamedata_session.query(Item).options(*processEager(eager)).join(*join).filter(filter).all() return items
def searchItems(nameLike, where=None, join=None, eager=None): if not isinstance(nameLike, basestring): raise TypeError("Need string as argument") if join is None: join = tuple() if not hasattr(join, "__iter__"): join = (join,) items = gamedata_session.query(Item).options(*processEager(eager)).join(*join) for token in nameLike.split(' '): token_safe = u"%{0}%".format(sqlizeString(token)) items = items.filter(processWhere(Item.name.like(token_safe, escape="\\"), where)) items = items.limit(100).all() return items
def searchItems(nameLike, where=None, join=None, eager=None): if not isinstance(nameLike, basestring): raise TypeError("Need string as argument") # Prepare our string for request nameLike = u"%{0}%".format(sqlizeString(nameLike)) if join is None: join = tuple() if not hasattr(join, "__iter__"): join = (join, ) filter = processWhere(Item.name.like(nameLike, escape="\\"), where) items = gamedata_session.query(Item).options(*processEager(eager)).join( *join).filter(filter).all() return items
def getBoosterFits(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 searchItems(nameLike, where=None, join=None, eager=None): if not isinstance(nameLike, basestring): raise TypeError("Need string as argument") if join is None: join = tuple() if not hasattr(join, "__iter__"): join = (join, ) items = gamedata_session.query(Item).options(*processEager(eager)).join( *join) for token in nameLike.split(' '): token_safe = u"%{0}%".format(sqlizeString(token)) items = items.filter( processWhere(Item.name.like(token_safe, escape="\\"), where)) items = items.limit(100).all() return items
def countFitsWithShip(shipID, ownerID=None, where=None, eager=None): """ Get all the fits using a certain ship. If no user is passed, do this for all users. """ if isinstance(shipID, int): if ownerID is not None and not isinstance(ownerID, int): raise TypeError("OwnerID must be integer") filter = Fit.shipID == shipID if ownerID is not None: filter = and_(filter, Fit.ownerID == ownerID) filter = processWhere(filter, where) eager = processEager(eager) with sd_lock: count = saveddata_session.query(Fit).options(*eager).filter(filter).count() else: raise TypeError("ShipID must be integer") return count