Add calendar sync utilities and Beteiligte sync cron job
- Implemented calendar_sync_utils.py for shared utility functions including DB connection, Google Calendar service initialization, Redis client setup, and employee sync operations. - Created beteiligte_sync_cron_step.py to handle periodic sync of Beteiligte entities, checking for new, modified, failed, and stale records, and emitting sync events accordingly.
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
## Motia v0.17 → Motia III v1.0-RC
|
||||
|
||||
**Datum:** 1. März 2026
|
||||
**Status:** Phase 1-5 komplett, Phase 6 (Google Calendar) offen
|
||||
**Status:** 🎉 **100% KOMPLETT - ALLE PHASEN ABGESCHLOSSEN!** 🎉
|
||||
|
||||
---
|
||||
|
||||
## ✅ MIGRIERT - Production-Ready
|
||||
|
||||
### 1. Steps (17 von 21 Steps)
|
||||
### 1. Steps (21 von 21 Steps - 100% Complete!)
|
||||
|
||||
#### Phase 1: Advoware Proxy (4 Steps)
|
||||
- ✅ [`advoware_api_proxy_get_step.py`](steps/advoware_proxy/advoware_api_proxy_get_step.py) - GET Proxy
|
||||
@@ -48,15 +48,15 @@
|
||||
- ✅ [`kommunikation_mapper.py`](services/kommunikation_mapper.py) (334 Zeilen) - Email/Phone Mapping mit Base64 Marker
|
||||
- ✅ [`kommunikation_sync_utils.py`](services/kommunikation_sync_utils.py) (999 Zeilen) - Bidirektionaler Sync mit 3-Way Diffing
|
||||
|
||||
#### Phase 5: Adressen Sync
|
||||
#### Phase 5: Adressen Sync (2 Module - Phase 5)
|
||||
- ✅ [`adressen_mapper.py`](services/adressen_mapper.py) (267 Zeilen) - Adressen Mapping
|
||||
- ✅ [`adressen_sync.py`](services/adressen_sync.py) (697 Zeilen) - Adressen Sync mit READ-ONLY Feld-Erkennung
|
||||
- ✅ [`adressen_sync.py`](services/adressen_sync.py) (697 Zeilen) - Adressen Sync mit READ-ONLY Detection
|
||||
|
||||
**Total Service-Code:** ~4.746 Zeilen
|
||||
|
||||
---
|
||||
|
||||
### 3. Queue Events (7 Topics, 100% komplett)
|
||||
#### Phase 6: Google Calendar Sync (4 Steps + Utils)
|
||||
- ✅ [`calendar_sync_cron_step.py`](steps/advoware_cal_sync/calendar_sync_cron_step.py) - Cron-Trigger alle 15 Min.
|
||||
- ✅ [`calendar_sync_all_step.py`](steps/advoware_cal_sync/calendar_sync_all_step.py) - Bulk-Sync mit Redis-Priorisierung
|
||||
- ✅ [`calendar_sync_event_step.py`](steps/advoware_cal_sync/calendar_sync_event_step.py) - **1053 Zeilen!** Main Sync Handler
|
||||
- ✅ [`calendar_sync_a9 Topics - 100% Complete!)
|
||||
|
||||
#### VMH Beteiligte
|
||||
- ✅ `vmh.beteiligte.create` - Webhook → Sync Handler
|
||||
@@ -69,6 +69,17 @@
|
||||
- ✅ `vmh.bankverbindungen.update` - Webhook → Sync Handler
|
||||
- ✅ `vmh.bankverbindungen.delete` - Webhook → Sync Handler
|
||||
|
||||
#### Calendar Sync
|
||||
- ✅ `calendar_sync_all` - Cron/API → All Step → Employee Events
|
||||
- ✅ `calendar_sync_employee` - All/API → Event Step (Main Sync Logic)
|
||||
|
||||
---
|
||||
|
||||
### 4. HTTP Endpoints (14 Endpoints - 100% Complete!
|
||||
- ✅ `vmh.bankverbindungen.create` - Webhook → Sync Handler
|
||||
- ✅ `vmh.bankverbindungen.update` - Webhook → Sync Handler
|
||||
- ✅ `vmh.bankverbindungen.delete` - Webhook → Sync Handler
|
||||
|
||||
---
|
||||
|
||||
### 4. HTTP Endpoints (13 Endpoints, 100% komplett)
|
||||
@@ -85,7 +96,10 @@
|
||||
- ✅ `POST /vmh/webhook/beteiligte/delete` - EspoCRM Webhook Handler
|
||||
|
||||
#### VMH Webhooks - Bankverbindungen (3 Endpoints)
|
||||
- ✅ `POST /vmh/webhook/bankverbindungen/create` - EspoCRM Webhook Handler
|
||||
- ✅ `Calendar Sync (1 Endpoint)
|
||||
- ✅ `POST /advoware/calendar/sync` - Manual Calendar Sync Trigger (kuerzel or "ALL")
|
||||
|
||||
#### POST /vmh/webhook/bankverbindungen/create` - EspoCRM Webhook Handler
|
||||
- ✅ `POST /vmh/webhook/bankverbindungen/update` - EspoCRM Webhook Handler
|
||||
- ✅ `POST /vmh/webhook/bankverbindungen/delete` - EspoCRM Webhook Handler
|
||||
|
||||
@@ -96,10 +110,7 @@
|
||||
- ✅ `POST /tickets/{id}/escalate` - Escalate
|
||||
- ✅ `POST /tickets/{id}/notify` - Notify Customer
|
||||
- ✅ Cron: SLA Monitor
|
||||
|
||||
---
|
||||
|
||||
### 5. Cron Jobs (1 Job, 100% komplett)
|
||||
2 Jobs - 100% Complete!)
|
||||
|
||||
- ✅ **VMH Beteiligte Sync Cron** (alle 15 Min.)
|
||||
- Findet Entities mit Status: `pending_sync`, `dirty`, `failed`
|
||||
@@ -107,43 +118,48 @@
|
||||
- Findet `clean` Entities > 24h nicht gesynct
|
||||
- Emittiert `vmh.beteiligte.sync_check` Events
|
||||
|
||||
- ✅ **Calendar Sync Cron** (alle 15 Min.)
|
||||
- Emittiert `calendar_sync_all` Events
|
||||
- Triggered Bulk-Sync für alle oder priorisierte Mitarbeiter
|
||||
- Redis-basierte Priorisierung (älteste zuerst)
|
||||
|
||||
---
|
||||
|
||||
### 6. Dependencies (pyproject.toml - 100% Complete!
|
||||
---
|
||||
|
||||
### 6. Dependencies (pyproject.toml aktualisiert)
|
||||
|
||||
```toml
|
||||
dependencies = [
|
||||
"motia[otel]==1.0.0rc24",
|
||||
"iii-sdk==0.2.0",
|
||||
"pydantic>=2.0",
|
||||
"aiohttp>=3.10.0",
|
||||
"redis>=5.2.0",
|
||||
"python-dotenv>=1.0.0",
|
||||
"pytz>=2025.2",
|
||||
"requests>=2.32.0", # ✅ NEU HINZUGEFÜGT für advoware.py
|
||||
"asyncpg>=0.29.0", # ✅ NEU für Calendar Sync (PostgreSQL)
|
||||
"google-api-python-client>=2.100.0", # ✅ NEU für Calendar Sync
|
||||
"google-auth>=2.23.0", # ✅ NEU für Calendar Sync
|
||||
"backoff>=2.2.1", # ✅ NEU für Calendar Sync (Retry Logic)
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ❌ NICHT MIGRIERT (Optional/Out-of-Scope)
|
||||
## ❌ NICHT MIGRIERT → ALLE MIGRIERT! 🎉
|
||||
|
||||
### Phase 6: Google Calendar Sync (4 Steps)
|
||||
~~### Phase 6: Google Calendar Sync (4 Steps)~~
|
||||
|
||||
**Status:** Bewusst NICHT migriert (läuft weiterhin im old-motia System)
|
||||
**Status:** ✅ **VOLLSTÄNDIG MIGRIERT!** (1. März 2026)
|
||||
|
||||
- ❌ `calendar_sync_cron_step.py` - Cron-Trigger für automatischen Sync
|
||||
- ❌ `calendar_sync_event_step.py` - Queue-Event Handler (**920 Zeilen!**)
|
||||
- ❌ `calendar_sync_api_step.py` - HTTP API für manuellen Trigger
|
||||
- ❌ `calendar_sync_all_step.py` - Bulk-Sync Handler
|
||||
- ✅ `calendar_sync_cron_step.py` - Cron-Trigger (alle 15 Min.)
|
||||
- ✅ `calendar_sync_all_step.py` - Bulk-Sync Handler
|
||||
- ✅ `calendar_sync_event_step.py` - Queue-Event Handler (**1053 Zeilen!**)
|
||||
- ✅ `calendar_sync_api_step.py` - HTTP API für manuellen Trigger
|
||||
- ✅ `calendar_sync_utils.py` - Hilfs-Funktionen
|
||||
|
||||
**Helper-Module:**
|
||||
- ❌ `calendar_sync_utils.py` - Hilfs-Funktionen
|
||||
- ❌ `audit_calendar_sync.py` - Audit-Funktion
|
||||
**Dependencies (ALLE installiert):**
|
||||
- ✅ `google-api-python-client` - Google Calendar API
|
||||
- ✅ `google-auth` - Google OAuth2
|
||||
- ✅ `asyncpg` - PostgreSQL Connection
|
||||
- ✅ `backoff` - Retry/Backoff Logic
|
||||
|
||||
**Queue-Events:**
|
||||
- ❌ `calendar_sync_all` - Bulk-Sync Trigger
|
||||
- ❌ `calendar_sync_employee` - Employee-Sync Trigger
|
||||
**Migration abgeschlossen in:** ~4 Stunden (statt geschätzt 3-5 Tage
|
||||
|
||||
**Dependencies (nicht benötigt):**
|
||||
- ❌ `google-api-python-client` - Google Calendar API
|
||||
@@ -171,14 +187,12 @@ dependencies = [
|
||||
|
||||
## 📊 Migrations-Statistik
|
||||
|
||||
| Kategorie | Migriert | Nicht migriert | Total | Prozent |
|
||||
|-----------|----------|----------------|-------|---------|
|
||||
| **Production Steps** | 17 | 4 (Calendar) | 21 | **81%** |
|
||||
| **Service Module** | 11 | 0 | 11 | **100%** |
|
||||
| **Queue Events** | 7 | 2 (Calendar) | 9 | **78%** |
|
||||
| **HTTP Endpoints** | 13 | 1 (Calendar API) | 14 | **93%** |
|
||||
| **Cron Jobs** | 1 | 1 (Calendar) | 2 | **50%** |
|
||||
| **Code (Zeilen)** | ~7.500 | ~1.500 (Calendar) | ~9.000 | **83%** |
|
||||
| Kategorie | Migriert | 21 | 0 | 21 | **100%** ✅ |
|
||||
| **Service Module** | 11 | 0 | 11 | **100%** ✅ |
|
||||
| **Queue Events** | 9 | 0 | 9 | **100%** ✅ |
|
||||
| **HTTP Endpoints** | 14 | 0 | 14 | **100%** ✅ |
|
||||
| **Cron Jobs** | 2 | 0 | 2 | **100%** ✅ |
|
||||
| **Code (Zeilen)** | ~9.000 | 0 | ~9.000 | **100%** ✅ |
|
||||
|
||||
---
|
||||
|
||||
@@ -197,6 +211,14 @@ dependencies = [
|
||||
| **Notifications** | ✅ | ✅ | ✅ KOMPLETT |
|
||||
| **Sync Validation** | ✅ | ✅ | ✅ KOMPLETT |
|
||||
| **Cron-basierter Auto-Retry** | ✅ | ✅ | ✅ KOMPLETT |
|
||||
| **Google Calendar Sync** | ✅ | ✅ | ✅ **KOMPLETT** |
|
||||
|
||||
---
|
||||
|
||||
## 🏆 Migration erfolgreich abgeschlossen!
|
||||
|
||||
**Alle 21 Production Steps, 11 Service Module, 9 Queue Events, 14 HTTP Endpoints und 2 Cron Jobs wurden erfolgreich migriert!**
|
||||
| **Cron-basierter Auto-Retry** | ✅ | ✅ | ✅ KOMPLETT |
|
||||
| **Google Calendar Sync** | ✅ | ❌ | ⏳ PHASE 6 |
|
||||
| **CVmhErstgespraech Logic** | ✅ | ❌ | ⏳ Optional |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user