Fix newbook_current_rates column names + rollback on failed date

- schema defined gross_rate/net_rate but every query (fetch job,
  bookability, competitors) uses rate_gross/rate_net — rename the
  columns, with an idempotent DO-block migration for existing tables
- roll back the session when a date fails so one bad statement no
  longer poisons the whole sync run (every subsequent write was dying
  with 'current transaction is aborted')

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-05 14:07:01 +00:00
parent 4977768645
commit 33d466ed73
3 changed files with 16 additions and 3 deletions

View file

@ -219,7 +219,7 @@ async def rate_comparison(
# Own hotel avg rate per date (across included categories)
own_result = await db.execute(
text("""
SELECT rate_date, AVG(gross_rate) AS own_rate
SELECT rate_date, AVG(rate_gross) AS own_rate
FROM newbook_current_rates
WHERE rate_date BETWEEN :from_date AND :to_date
GROUP BY rate_date