make task processing a bit better. still doing 1 query to check if needs processing; will fix later
This commit is contained in:
parent
87efe0694c
commit
d1cef99c5a
2 changed files with 39 additions and 9 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue