diff --git a/titles/idac/schema/factory_db.py b/titles/idac/schema/factory_db.py index 9bb1bc3..319605e 100644 --- a/titles/idac/schema/factory_db.py +++ b/titles/idac/schema/factory_db.py @@ -20,8 +20,10 @@ class IDACFactoryDb(BaseData): self.mapper = IDACFactoryMapper() async def get_lottery(self, aime_id: int, version: int) -> Optional[LotteryDto]: - sql = select(LotteryDb).where( - and_(LotteryDb.user == aime_id, LotteryDb.version == version) + sql = ( + select(LotteryDb) + .where(and_(LotteryDb.user == aime_id, LotteryDb.version <= version)) + .order_by(LotteryDb.version.desc()) ) result = await self.execute(sql) lottery_db = result.scalars().first() @@ -96,7 +98,6 @@ class IDACFactoryDb(BaseData): return None return self.mapper.car_to_dto(car_db) - async def get_cars( self, version: int, aime_id: int, only_pickup: bool = False ) -> Optional[List[CarDto]]: