Fix buy listing support: thread ListingType through processing pipeline
The listing processor was hardcoded to create RentListing objects and query only the rentlisting table. Buy listings fetched from Rightmove were stored in the wrong table with missing fields. This threads ListingType through ListingProcessor and all Step subclasses so the correct model (RentListing/BuyListing) is created, the correct table is queried, and buy-specific fields (service_charge, lease_left) are parsed from the API response and included in GeoJSON streaming output.
This commit is contained in:
parent
5e48a26958
commit
e5ce8c1201
6 changed files with 116 additions and 41 deletions
|
|
@ -20,7 +20,8 @@ logger = logging.getLogger("uvicorn.error")
|
|||
STREAMING_COLUMNS = [
|
||||
'id', 'price', 'number_of_bedrooms', 'square_meters',
|
||||
'longitude', 'latitude', 'photo_thumbnail', 'last_seen',
|
||||
'agency', 'price_history_json', 'available_from'
|
||||
'agency', 'price_history_json', 'available_from',
|
||||
'service_charge', 'lease_left',
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -348,8 +349,9 @@ class ListingRepository:
|
|||
result = session.execute(sa_select(model.id))
|
||||
return {row[0] for row in result.fetchall()}
|
||||
|
||||
async def mark_seen(self, listing_id: int) -> None:
|
||||
listings = await self.get_listings(only_ids=[listing_id])
|
||||
async def mark_seen(self, listing_id: int, listing_type: ListingType = ListingType.RENT) -> None:
|
||||
query_params = QueryParameters(listing_type=listing_type)
|
||||
listings = await self.get_listings(only_ids=[listing_id], query_parameters=query_params)
|
||||
if len(listings) == 0:
|
||||
return
|
||||
listing = listings[0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue