- Introduced a new scheduled task for executing automation rules every 5 minutes in the Celery beat schedule. - Updated URL routing to include a new endpoint for automation-related functionalities. - Refactored imports in various modules to align with the new business layer structure, ensuring backward compatibility for billing models, exceptions, and services.
29 lines
825 B
Python
29 lines
825 B
Python
"""
|
|
Automation Celery Tasks
|
|
"""
|
|
from celery import shared_task
|
|
import logging
|
|
from igny8_core.business.automation.services.automation_service import AutomationService
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@shared_task(name='igny8_core.business.automation.tasks.execute_scheduled_automation_rules')
|
|
def execute_scheduled_automation_rules():
|
|
"""
|
|
Execute all scheduled automation rules.
|
|
Called by Celery Beat.
|
|
"""
|
|
try:
|
|
service = AutomationService()
|
|
result = service.execute_scheduled_rules()
|
|
logger.info(f"Executed scheduled automation rules: {result}")
|
|
return result
|
|
except Exception as e:
|
|
logger.error(f"Error executing scheduled automation rules: {str(e)}", exc_info=True)
|
|
return {
|
|
'success': False,
|
|
'error': str(e)
|
|
}
|
|
|