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