40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
import json
|
|
import redis
|
|
from config import Config
|
|
from services.advoware import AdvowareAPI
|
|
from .calendar_sync_utils import log_operation
|
|
|
|
config = {
|
|
'type': 'cron',
|
|
'name': 'Calendar Sync Cron Job',
|
|
'description': 'Führt den Calendar Sync alle 15 Minuten automatisch aus',
|
|
'cron': '*/15 * * * *', # Alle 15 Minuten
|
|
'emits': ['calendar_sync_all'],
|
|
'flows': ['advoware']
|
|
}
|
|
|
|
async def handler(context):
|
|
try:
|
|
log_operation('info', "Calendar Sync Cron: Starting to emit sync-all event", context=context)
|
|
|
|
# # Emit sync-all event
|
|
await context.emit({
|
|
"topic": "calendar_sync_all",
|
|
"data": {
|
|
"triggered_by": "cron"
|
|
}
|
|
})
|
|
|
|
log_operation('info', "Calendar Sync Cron: Emitted sync-all event", context=context)
|
|
return {
|
|
'status': 'completed',
|
|
'triggered_by': 'cron'
|
|
}
|
|
|
|
except Exception as e:
|
|
log_operation('error', f"Fehler beim Cron-Job: {e}", context=context)
|
|
return {
|
|
'status': 'error',
|
|
'error': str(e)
|
|
}
|