✨ Add status filter to report generation
- 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
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user