From 309de51744ccef9cdfbd7232b22d9748082b9d91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=91=D0=B4=D0=BE=D1=80?= Date: Mon, 27 Oct 2025 23:16:29 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20status=20filter=20to=20report?= =?UTF-8?q?=20generation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added ONLY_ACTIVE parameter to filter by hotel status - Now supports generating reports for 'Действует' (Active) hotels only - Default: ONLY_ACTIVE = True (Orel region configured) - Can be easily toggled for all statuses Changes: - create_horizontal_report.py: Added status_name filter in SQL query - Tested on Orel region: 29 active hotels (out of 30 total) - Average score: 44.1%, RKN registry: 26 hotels --- create_horizontal_report.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/create_horizontal_report.py b/create_horizontal_report.py index 6f1baf4..610bcc8 100644 --- a/create_horizontal_report.py +++ b/create_horizontal_report.py @@ -42,8 +42,9 @@ DB_CONFIG = { } # ========== НАСТРОЙКИ РЕГИОНА ========== -REGION = 'г. Санкт-Петербург' # Измените на нужный регион +REGION = 'Орловская область' # Измените на нужный регион AUDIT_VERSION = 'v1.0_with_rkn' # Версия аудита +ONLY_ACTIVE = True # Только действующие отели (status_name = 'Действует') # ======================================= def get_region_data(): @@ -52,7 +53,11 @@ def get_region_data(): cur = conn.cursor() # Получаем данные аудита с информацией об отелях - cur.execute(""" + status_filter = "" + if ONLY_ACTIVE: + status_filter = "AND hm.status_name = 'Действует'" + + cur.execute(f""" SELECT har.hotel_id, har.hotel_name, @@ -85,11 +90,13 @@ def get_region_data(): hm.phone, hm.email, hm.category_name, - hm.registry_url + hm.registry_url, + hm.status_name FROM hotel_audit_results har LEFT JOIN hotel_main hm ON hm.id = har.hotel_id WHERE har.region_name = %s AND har.audit_version = %s + {status_filter} ORDER BY har.score_percentage DESC """, (REGION, AUDIT_VERSION))