Fix otaceni fotek, drobny refaktoring
This commit is contained in:
@@ -12,11 +12,11 @@ class PhotoMutationResolver(BaseMutationResolver):
|
||||
def __init__(self):
|
||||
super().__init__(Photo, models.Photo)
|
||||
|
||||
async def reset_flight_cover(self, db: AsyncSession, flight_id: int):
|
||||
async def reset_flight_cover(self, db: AsyncSession, flight_id: int, ignored_photo_id: int):
|
||||
(await db.execute(
|
||||
update(models.Photo)
|
||||
.filter(models.Photo.flight_id == flight_id)
|
||||
.filter(models.Photo.id != id).values(is_flight_cover=False))
|
||||
.filter(models.Photo.id != ignored_photo_id).values(is_flight_cover=False))
|
||||
)
|
||||
|
||||
async def update(self, id: int, input: EditPhotoInput, user_id: int) -> Photo:
|
||||
@@ -35,6 +35,6 @@ class PhotoMutationResolver(BaseMutationResolver):
|
||||
|
||||
if input.is_flight_cover:
|
||||
# reset other covers
|
||||
await self.reset_flight_cover(db, photo.flight_id)
|
||||
await self.reset_flight_cover(db, photo.flight_id, id)
|
||||
|
||||
return await self._do_update(db, obj=photo, data=data)
|
||||
|
||||
Reference in New Issue
Block a user