From 4977768645d9b62c9878fb11907dc60115444b41 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Sun, 5 Jul 2026 14:01:07 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20sites=5Flist=20category=20field=20names?= =?UTF-8?q?=20=E2=80=94=20category=5Fid/category=5Fname,=20not=20site=5Fca?= =?UTF-8?q?tegory=5F*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rates Newbook instance returns categories as category_id/category_name on each site; also skip inactive categories. Co-Authored-By: Claude Fable 5 --- backend/services/newbook_rates_client.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/services/newbook_rates_client.py b/backend/services/newbook_rates_client.py index 41f3447..80685e1 100644 --- a/backend/services/newbook_rates_client.py +++ b/backend/services/newbook_rates_client.py @@ -97,8 +97,9 @@ class NewbookRatesClient: """ Fetch room categories by grouping the sites_list endpoint. - Each site includes site_category_id and site_category_name; categories + Each site carries its category as category_id/category_name; categories are derived by grouping sites and counting rooms per category. + Inactive categories (category_active = "0") are skipped. Returns: List of dicts with {category_id, category_name, room_count} @@ -114,12 +115,14 @@ class NewbookRatesClient: categories: Dict[str, Dict] = {} for site in sites: - cat_id = str(site.get("site_category_id") or "") + cat_id = str(site.get("category_id") or site.get("site_category_id") or "") if not cat_id: continue + if str(site.get("category_active", "1")) == "0": + continue entry = categories.setdefault(cat_id, { "category_id": cat_id, - "category_name": site.get("site_category_name") or f"Category {cat_id}", + "category_name": site.get("category_name") or site.get("site_category_name") or f"Category {cat_id}", "room_count": 0, }) entry["room_count"] += 1