✨ Major Features: - Complete RAG system for hotel website analysis - Hybrid audit with BGE-M3 embeddings + Natasha NER - Universal horizontal Excel reports with dashboards - Multi-region processing (SPb, Orel, Chukotka, Kamchatka) 📊 Completed Regions: - Орловская область: 100% (36/36) - Чукотский АО: 100% (4/4) - г. Санкт-Петербург: 93% (893/960) - Камчатский край: 87% (89/102) 🔧 Infrastructure: - PostgreSQL with pgvector extension - BGE-M3 embeddings API - Browserless for web scraping - N8N workflows for automation - S3/Nextcloud file storage 📝 Documentation: - Complete DB schemas - API documentation - Setup guides - Status reports
92 lines
2.9 KiB
Python
92 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
Мониторинг восстановления базы данных
|
||
"""
|
||
|
||
from urllib.parse import unquote
|
||
import psycopg2
|
||
import time
|
||
from datetime import datetime
|
||
|
||
DB_CONFIG = {
|
||
'host': "147.45.189.234",
|
||
'database': "default_db",
|
||
'user': "gen_user",
|
||
'password': unquote("2~~9_%5EkVsU%3F2%5CS"),
|
||
'connect_timeout': 5
|
||
}
|
||
|
||
def check_db():
|
||
"""Проверить состояние БД"""
|
||
try:
|
||
conn = psycopg2.connect(**DB_CONFIG)
|
||
cur = conn.cursor()
|
||
|
||
# Проверим базовые таблицы
|
||
cur.execute('SELECT COUNT(*) FROM hotel_main')
|
||
hotels = cur.fetchone()[0]
|
||
|
||
cur.execute('SELECT COUNT(*) FROM hotel_main WHERE region_name = %s', ('Чукотский автономный округ',))
|
||
chukotka = cur.fetchone()[0]
|
||
|
||
cur.execute('''
|
||
SELECT
|
||
COUNT(DISTINCT h.id) as total,
|
||
COUNT(DISTINCT p.hotel_id) as processed
|
||
FROM hotel_main h
|
||
LEFT JOIN hotel_website_processed p ON p.hotel_id = h.id
|
||
WHERE h.region_name = 'г. Санкт-Петербург'
|
||
AND h.website_address IS NOT NULL
|
||
AND h.website_address != ''
|
||
AND h.website_address != 'Нет'
|
||
''')
|
||
|
||
spb_total, spb_processed = cur.fetchone()
|
||
|
||
cur.close()
|
||
conn.close()
|
||
|
||
return {
|
||
'status': 'OK',
|
||
'hotels_total': hotels,
|
||
'chukotka_hotels': chukotka,
|
||
'spb_total': spb_total,
|
||
'spb_processed': spb_processed,
|
||
'spb_percent': spb_processed/spb_total*100 if spb_total > 0 else 0
|
||
}
|
||
|
||
except Exception as e:
|
||
return {'status': 'ERROR', 'error': str(e)}
|
||
|
||
def main():
|
||
"""Мониторинг восстановления"""
|
||
print("🔍 МОНИТОРИНГ ВОССТАНОВЛЕНИЯ БД")
|
||
print("=" * 50)
|
||
|
||
start_time = datetime.now()
|
||
|
||
while True:
|
||
current_time = datetime.now()
|
||
elapsed = (current_time - start_time).total_seconds()
|
||
|
||
result = check_db()
|
||
|
||
if result['status'] == 'OK':
|
||
print(f"🎉 БД ВОССТАНОВЛЕНА! Время восстановления: {elapsed/60:.1f} мин")
|
||
print(f"📊 Статистика:")
|
||
print(f" Всего отелей: {result['hotels_total']}")
|
||
print(f" Чукотка: {result['chukotka_hotels']} отелей")
|
||
print(f" СПб: {result['spb_processed']}/{result['spb_total']} ({result['spb_percent']:.1f}%)")
|
||
break
|
||
else:
|
||
print(f"[{current_time.strftime('%H:%M:%S')}] ❌ БД недоступна: {result['error']}")
|
||
|
||
time.sleep(30) # Проверяем каждые 30 секунд
|
||
|
||
if __name__ == "__main__":
|
||
main()
|
||
|
||
|
||
|
||
|