Fix own hotel excluded from scrape and 1-person rates hidden in matrix

Include tier=own in get_active_hotels() so the own hotel Booking.com
listing is scraped alongside competitors. Change matrix max_persons
filter from hard WHERE to ORDER BY priority so hotels with only
1-person rates (e.g. Old Stocks) still show up rather than being
silently excluded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-10 00:31:08 +00:00
parent ca76bc2f90
commit dd84ca230a
2 changed files with 10 additions and 8 deletions

View file

@ -778,8 +778,9 @@ async def get_competitor_matrix(
WHERE {tier_filter}
AND h.is_active = TRUE
AND r.rate_date >= :from_date AND r.rate_date <= :to_date
AND (r.max_persons IS NULL OR r.max_persons = 2)
ORDER BY r.hotel_id, r.rate_date, r.scraped_at DESC, r.rate_gross ASC NULLS LAST
ORDER BY r.hotel_id, r.rate_date,
CASE WHEN r.max_persons IS NULL OR r.max_persons = 2 THEN 0 ELSE 1 END,
r.scraped_at DESC, r.rate_gross ASC NULLS LAST
"""),
{'from_date': start, 'to_date': end}
)
@ -818,8 +819,9 @@ async def get_competitor_matrix(
AND r.rate_date >= :from_date AND r.rate_date <= :to_date
AND r.availability_status = 'available'
AND r.rate_gross IS NOT NULL
AND (r.max_persons IS NULL OR r.max_persons = 2)
ORDER BY r.hotel_id, r.rate_date, r.scraped_at DESC, r.rate_gross ASC NULLS LAST
ORDER BY r.hotel_id, r.rate_date,
CASE WHEN r.max_persons IS NULL OR r.max_persons = 2 THEN 0 ELSE 1 END,
r.scraped_at DESC, r.rate_gross ASC NULLS LAST
"""),
{'from_date': start, 'to_date': end}
)