Fix uuid type mismatch in stale batch cleanup subqueries

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 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-15 09:18:18 +00:00
parent 6503018b99
commit 8a80c66a3b

View file

@ -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'