- Краулеры: smart_crawler.py, regional_crawler.py - Аудит: audit_orel_to_excel.py, audit_chukotka_to_excel.py - РКН проверка: check_rkn_registry.py, recheck_unclear_rkn.py - Отчёты: create_orel_horizontal_report.py - Обработка: process_all_hotels_embeddings.py - Документация: README.md, DB_SCHEMA_REFERENCE.md
73 lines
2.3 KiB
Python
73 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
Тестовый скрипт для проверки обработки данных
|
||
"""
|
||
|
||
import psycopg2
|
||
import json
|
||
from urllib.parse import unquote
|
||
|
||
# Конфигурация БД
|
||
DB_CONFIG = {
|
||
'host': '147.45.189.234',
|
||
'port': 5432,
|
||
'database': 'default_db',
|
||
'user': 'gen_user',
|
||
'password': unquote('2~~9_%5EkVsU%3F2%5CS')
|
||
}
|
||
|
||
def test_data_processing():
|
||
"""Тестируем обработку данных"""
|
||
conn = psycopg2.connect(**DB_CONFIG)
|
||
cur = conn.cursor()
|
||
|
||
cur.execute('SELECT criteria_results FROM hotel_audit_results LIMIT 1')
|
||
row = cur.fetchone()
|
||
|
||
if row:
|
||
criteria = row[0]
|
||
print('🔍 Исходные данные из БД:')
|
||
print(f' Тип: {type(criteria)}')
|
||
print(f' Длина: {len(criteria)}')
|
||
|
||
# Проверяем критерий 2
|
||
criterion_02 = criteria.get('criterion_02', {})
|
||
print(f'\n📋 Критерий 2 (Адрес):')
|
||
print(f' found: {criterion_02.get("found")}')
|
||
print(f' approval_urls: {criterion_02.get("approval_urls")}')
|
||
print(f' quote: {criterion_02.get("quote", "")[:50]}...')
|
||
|
||
# Тестируем обработку
|
||
print(f'\n🔧 Тестируем обработку:')
|
||
|
||
# URL
|
||
url = '-'
|
||
if criterion_02.get('approval_urls'):
|
||
url = criterion_02['approval_urls'][0]
|
||
print(f' URL: {url}')
|
||
|
||
# Комментарий
|
||
comment = "Не найдено"
|
||
if criterion_02['found']:
|
||
if criterion_02.get('quote'):
|
||
comment = criterion_02['quote']
|
||
elif criterion_02.get('approval_quotes'):
|
||
first_quote = criterion_02['approval_quotes'][0]
|
||
if isinstance(first_quote, dict):
|
||
comment = first_quote.get('quote', 'Найдено')
|
||
else:
|
||
comment = str(first_quote)
|
||
else:
|
||
comment = "Найдено"
|
||
|
||
comment = comment[:100] + "..." if len(comment) > 100 else comment
|
||
|
||
print(f' Комментарий: {comment[:50]}...')
|
||
|
||
cur.close()
|
||
conn.close()
|
||
|
||
if __name__ == "__main__":
|
||
test_data_processing()
|
||
|