From d72f14ae49fa0a71f8ba4fc3b58fc4043a52d340 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Fri, 10 Jul 2026 08:41:58 +0000 Subject: [PATCH] Fix bookability column timestamps showing stale 'last changed' dates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch date_last_updated from valid_from (rate change time) to last_verified_at (last check time). All dates verified in the same daily run now show a consistent timestamp rather than varying by when rates last changed. Also commit per-date instead of batching 10 days — prevents a single API error from rolling back up to 9 preceding committed dates. Co-Authored-By: Claude Sonnet 4.6 --- backend/api/bookability.py | 9 ++++++--- backend/jobs/fetch_current_rates.py | 2 +- frontend/src/index.css | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/backend/api/bookability.py b/backend/api/bookability.py index 0713e68..b240afb 100644 --- a/backend/api/bookability.py +++ b/backend/api/bookability.py @@ -242,7 +242,7 @@ async def get_rate_matrix( # Fetch rates with tariffs_data (get latest version per category/date) rates_query = """ SELECT DISTINCT ON (category_id, rate_date) - category_id, rate_date, rate_gross, rate_net, tariffs_data, valid_from + category_id, rate_date, rate_gross, rate_net, tariffs_data, valid_from, last_verified_at FROM newbook_current_rates WHERE rate_date >= :from_date AND rate_date <= :to_date """ @@ -338,6 +338,7 @@ async def get_rate_matrix( # Preserve existing occupancy data existing_occ = matrix[cat_id][rate_date].occupancy vf = row.valid_from.isoformat() if row.valid_from else None + lv = row.last_verified_at.isoformat() if row.last_verified_at else vf matrix[cat_id][rate_date] = DateRateInfo( rate_gross=float(row.rate_gross) if row.rate_gross else None, @@ -345,10 +346,12 @@ async def get_rate_matrix( tariffs=tariffs_list, tariff_count=tariffs_data.get('tariff_count', len(tariffs_list)), occupancy=existing_occ, - valid_from=vf + valid_from=lv ) - # Per-date latest update time (max valid_from across all categories for each date) + # Per-date latest check time (max last_verified_at across all categories for each date) + # Use last_verified_at so the header reflects when data was last CHECKED, not when rates last changed. + # This makes all dates verified in the same daily run show a consistent timestamp. date_last_updated: Dict[str, Optional[str]] = {} for date_str in dates: latest = None diff --git a/backend/jobs/fetch_current_rates.py b/backend/jobs/fetch_current_rates.py index e43d135..a07766c 100644 --- a/backend/jobs/fetch_current_rates.py +++ b/backend/jobs/fetch_current_rates.py @@ -26,7 +26,7 @@ from database import SyncSessionLocal logger = logging.getLogger(__name__) -COMMIT_BATCH_SIZE = 10 # Commit to DB every N days +COMMIT_BATCH_SIZE = 1 # Commit after every date — prevents rollback from wiping sibling days on API error def rates_changed(old_rate: Optional[Dict], new_rate: Dict) -> bool: diff --git a/frontend/src/index.css b/frontend/src/index.css index 1c0146a..8f3b4af 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -361,3 +361,18 @@ tr:hover td { background: #f8fafc; } padding: 16px; } } + +/* Sidebar scrollbar */ +.nav-scroll::-webkit-scrollbar, +.sidebar::-webkit-scrollbar, +.sidebar-nav::-webkit-scrollbar { width: 4px; } +.nav-scroll::-webkit-scrollbar-track, +.sidebar::-webkit-scrollbar-track, +.sidebar-nav::-webkit-scrollbar-track { background: transparent; } +.nav-scroll::-webkit-scrollbar-thumb, +.sidebar::-webkit-scrollbar-thumb, +.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.35); border-radius: 2px; } +.nav-scroll::-webkit-scrollbar-thumb:hover, +.sidebar::-webkit-scrollbar-thumb:hover, +.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(201,168,76,0.65); } +.nav-scroll, .sidebar, .sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(201,168,76,0.35) transparent; }