feat: Enhance document synchronization logic to continue syncing after collection activation
This commit is contained in:
@@ -155,8 +155,10 @@ class AIKnowledgeSync(BaseSyncUtils):
|
|||||||
})
|
})
|
||||||
|
|
||||||
ctx.logger.info(f"✅ Collection created: {collection_id}")
|
ctx.logger.info(f"✅ Collection created: {collection_id}")
|
||||||
ctx.logger.info(" Status changed to 'active', next webhook will sync documents")
|
ctx.logger.info(" Status changed to 'active', now syncing documents...")
|
||||||
return
|
|
||||||
|
# Continue to document sync immediately (don't return)
|
||||||
|
# Fall through to sync logic below
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════
|
# ═══════════════════════════════════════════════════════════
|
||||||
# CASE 2: DEACTIVATED → Delete Collection from XAI
|
# CASE 2: DEACTIVATED → Delete Collection from XAI
|
||||||
@@ -202,13 +204,14 @@ class AIKnowledgeSync(BaseSyncUtils):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════
|
# ═══════════════════════════════════════════════════════════
|
||||||
# CASE 4: ACTIVE → Normal Sync
|
# CASE 4: ACTIVE → Normal Sync (or just created from NEW)
|
||||||
# ═══════════════════════════════════════════════════════════
|
# ═══════════════════════════════════════════════════════════
|
||||||
elif activation_status == AIKnowledgeActivationStatus.ACTIVE.value:
|
if activation_status in (AIKnowledgeActivationStatus.ACTIVE.value, AIKnowledgeActivationStatus.NEW.value):
|
||||||
if not collection_id:
|
if not collection_id:
|
||||||
ctx.logger.error("❌ Status 'active' but no datenbankId!")
|
ctx.logger.error("❌ Status 'active' but no datenbankId!")
|
||||||
raise RuntimeError("Active knowledge without collection ID")
|
raise RuntimeError("Active knowledge without collection ID")
|
||||||
|
|
||||||
|
if activation_status == AIKnowledgeActivationStatus.ACTIVE.value:
|
||||||
ctx.logger.info(f"🔄 Status 'active' → Syncing documents to {collection_id}")
|
ctx.logger.info(f"🔄 Status 'active' → Syncing documents to {collection_id}")
|
||||||
|
|
||||||
# Verify collection exists
|
# Verify collection exists
|
||||||
@@ -227,10 +230,10 @@ class AIKnowledgeSync(BaseSyncUtils):
|
|||||||
'datenbankId': collection_id
|
'datenbankId': collection_id
|
||||||
})
|
})
|
||||||
|
|
||||||
# Sync documents
|
# Sync documents (both for ACTIVE status and after NEW → ACTIVE transition)
|
||||||
await self._sync_knowledge_documents(knowledge_id, collection_id, ctx)
|
await self._sync_knowledge_documents(knowledge_id, collection_id, ctx)
|
||||||
|
|
||||||
else:
|
elif activation_status not in (AIKnowledgeActivationStatus.DEACTIVATED.value, AIKnowledgeActivationStatus.PAUSED.value):
|
||||||
ctx.logger.error(f"❌ Unknown aktivierungsstatus: {activation_status}")
|
ctx.logger.error(f"❌ Unknown aktivierungsstatus: {activation_status}")
|
||||||
raise ValueError(f"Invalid aktivierungsstatus: {activation_status}")
|
raise ValueError(f"Invalid aktivierungsstatus: {activation_status}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user