From 8a80c66a3b567acd944ad31e201ba1d72287320c Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Wed, 15 Jul 2026 09:18:18 +0000 Subject: [PATCH] Fix uuid type mismatch in stale batch cleanup subqueries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scrape_batch_id in booking_com_rates is a uuid column, not text. Casting bsl.batch_id::text made the comparison uuid = text which Postgres rejects. Drop the cast — both sides are uuid. Co-Authored-By: Claude Sonnet 4.6 --- backend/services/booking_scraper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/services/booking_scraper.py b/backend/services/booking_scraper.py index 3a5f310..c080aa1 100644 --- a/backend/services/booking_scraper.py +++ b/backend/services/booking_scraper.py @@ -76,13 +76,13 @@ def force_reset_scraper(db: Session) -> dict: hotels_found = ( SELECT COUNT(DISTINCT hotel_id) FROM booking_com_rates - WHERE scrape_batch_id = bsl.batch_id::text + WHERE scrape_batch_id = bsl.batch_id AND rate_gross IS NOT NULL ), rates_scraped = ( SELECT COUNT(*) FROM booking_com_rates - WHERE scrape_batch_id = bsl.batch_id::text + WHERE scrape_batch_id = bsl.batch_id AND rate_gross IS NOT NULL ) WHERE status = 'running' @@ -304,13 +304,13 @@ def cleanup_stale_batches(db: Session, max_age_minutes: int = 60): hotels_found = ( SELECT COUNT(DISTINCT hotel_id) FROM booking_com_rates - WHERE scrape_batch_id = bsl.batch_id::text + WHERE scrape_batch_id = bsl.batch_id AND rate_gross IS NOT NULL ), rates_scraped = ( SELECT COUNT(*) FROM booking_com_rates - WHERE scrape_batch_id = bsl.batch_id::text + WHERE scrape_batch_id = bsl.batch_id AND rate_gross IS NOT NULL ) WHERE bsl.status = 'running'