ECVI, RealtyCalendar Pliugins bugfix
Reports displaying
This commit is contained in:
@@ -78,6 +78,53 @@ async def delete_hotel(update: Update, context):
|
||||
await query.edit_message_text("Отель не найден.")
|
||||
|
||||
|
||||
# async def check_pms(update, context):
|
||||
# query = update.callback_query
|
||||
|
||||
# try:
|
||||
# # Получение ID отеля из callback_data
|
||||
# hotel_id = query.data.split("_")[2]
|
||||
# logger.debug(f"Hotel ID: {hotel_id}")
|
||||
# logger.debug(f"Hotel ID type : {type(hotel_id)}")
|
||||
# # Получение конфигурации отеля и PMS
|
||||
# hotel = await sync_to_async(Hotel.objects.select_related('pms').get)(id=hotel_id)
|
||||
# pms_config = hotel.pms
|
||||
|
||||
# if not pms_config:
|
||||
# await query.edit_message_text("PMS конфигурация не найдена.")
|
||||
# return
|
||||
|
||||
# # Создаем экземпляр PMSIntegrationManager
|
||||
# pms_manager = PMSIntegrationManager(hotel_id=hotel_id)
|
||||
# await pms_manager.load_hotel()
|
||||
# await sync_to_async(pms_manager.load_plugin)()
|
||||
|
||||
# # Проверяем, какой способ интеграции использовать
|
||||
# if hasattr(pms_manager.plugin, 'fetch_data') and callable(pms_manager.plugin.fetch_data):
|
||||
# # Плагин поддерживает метод fetch_data
|
||||
# report = await pms_manager.plugin._fetch_data()
|
||||
|
||||
# else:
|
||||
# await query.edit_message_text("Подходящий способ интеграции с PMS не найден.")
|
||||
# return
|
||||
|
||||
# # Формируем сообщение о результатах
|
||||
# result_message = (
|
||||
# f"Интеграция PMS завершена успешно.\n"
|
||||
# f"Обработано интервалов: {report['processed_intervals']}\n"
|
||||
# f"Обработано записей: {report['processed_items']}\n"
|
||||
# f"Ошибки: {len(report['errors'])}"
|
||||
# )
|
||||
# logger.info(f'Result_Message: {result_message}\n Result_meaage_type: {type(result_message)}')
|
||||
# if report["errors"]:
|
||||
# result_message += "\n\nСписок ошибок:\n" + "\n".join(report["errors"])
|
||||
|
||||
# await query.edit_message_text(result_message)
|
||||
# except Exception as e:
|
||||
# # Обрабатываем и логируем ошибки
|
||||
# await query.edit_message_text(f"❌ Ошибка: {str(e)}")
|
||||
|
||||
|
||||
async def check_pms(update, context):
|
||||
query = update.callback_query
|
||||
|
||||
@@ -86,6 +133,7 @@ async def check_pms(update, context):
|
||||
hotel_id = query.data.split("_")[2]
|
||||
logger.debug(f"Hotel ID: {hotel_id}")
|
||||
logger.debug(f"Hotel ID type : {type(hotel_id)}")
|
||||
|
||||
# Получение конфигурации отеля и PMS
|
||||
hotel = await sync_to_async(Hotel.objects.select_related('pms').get)(id=hotel_id)
|
||||
pms_config = hotel.pms
|
||||
@@ -103,29 +151,37 @@ async def check_pms(update, context):
|
||||
if hasattr(pms_manager.plugin, 'fetch_data') and callable(pms_manager.plugin.fetch_data):
|
||||
# Плагин поддерживает метод fetch_data
|
||||
report = await pms_manager.plugin._fetch_data()
|
||||
|
||||
logger.debug(f"REPORT: {report}, TYPE: {type(report)}")
|
||||
else:
|
||||
await query.edit_message_text("Подходящий способ интеграции с PMS не найден.")
|
||||
return
|
||||
|
||||
# Проверяем результат выполнения fetch_data
|
||||
if not report or not isinstance(report, dict):
|
||||
logger.error(f"Некорректный отчет от fetch_data: {report}")
|
||||
await query.edit_message_text("Ошибка: Отчет fetch_data отсутствует или имеет некорректный формат.")
|
||||
return
|
||||
|
||||
# Формируем сообщение о результатах
|
||||
result_message = (
|
||||
f"Интеграция PMS завершена успешно.\n"
|
||||
f"Обработано интервалов: {report['processed_intervals']}\n"
|
||||
f"Обработано записей: {report['processed_items']}\n"
|
||||
f"Ошибки: {len(report['errors'])}"
|
||||
f"Обработано интервалов: {report.get('processed_intervals', 0)}\n"
|
||||
f"Обработано записей: {report.get('processed_items', 0)}\n"
|
||||
f"Ошибки: {len(report.get('errors', []))}"
|
||||
)
|
||||
logger.info(f'Result_Message: {result_message}\n Result_meaage_type: {type(result_message)}')
|
||||
if report["errors"]:
|
||||
if report.get("errors"):
|
||||
result_message += "\n\nСписок ошибок:\n" + "\n".join(report["errors"])
|
||||
|
||||
logger.info(f"Result_Message: {result_message}")
|
||||
await query.edit_message_text(result_message)
|
||||
except Exception as e:
|
||||
# Обрабатываем и логируем ошибки
|
||||
logger.error(f"Ошибка в методе check_pms: {str(e)}", exc_info=True)
|
||||
await query.edit_message_text(f"❌ Ошибка: {str(e)}")
|
||||
|
||||
|
||||
|
||||
|
||||
async def setup_rooms(update: Update, context):
|
||||
"""Настроить номера отеля."""
|
||||
query = update.callback_query
|
||||
|
||||
Reference in New Issue
Block a user