make task processing a bit better. still doing 1 query to check if needs processing; will fix later

This commit is contained in:
Viktor Barzin 2025-07-27 20:09:41 +00:00
parent 87efe0694c
commit d1cef99c5a
No known key found for this signature in database
GPG key ID: 4056458DBDBF8863
2 changed files with 39 additions and 9 deletions

View file

@ -54,6 +54,14 @@ class Step:
class FetchListingDetailsStep(Step):
async def needs_processing(self, listing_id: int) -> bool:
existing_listings = await self.listing_repository.get_listings(
only_ids=[listing_id]
)
if (existing_listings) == 0:
return True
return False
async def process(self, listing_id: int) -> Listing:
logger.debug(f"Fetching details for {listing_id=}")
existing_listings = await self.listing_repository.get_listings(
@ -115,6 +123,15 @@ class FetchListingDetailsStep(Step):
class FetchImagesStep(Step):
async def needs_processing(self, listing_id: int) -> bool:
existing_listings = await self.listing_repository.get_listings(
only_ids=[listing_id]
)
if len(existing_listings) == 0:
return False # if listing doesn't exist, we can't process it
listing = existing_listings[0]
return len(listing.floorplan_image_paths) == 0
async def process(self, listing_id: int) -> Listing:
logger.debug(f"Fetching images for {listing_id=}")
existing_listings = await self.listing_repository.get_listings(